loureirorg / mwsx Goto Github PK
View Code? Open in Web Editor NEWAjax library
Ajax library
Most PHP libraries are now complying with the PSR-0 standard for autoloader interoperability.
What about make the simplest modification to comply with this standard?
The PSR-0 standard: https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-0.md
Other resource:
http://gilbertoalbino.com/conheca-o-padrao-psr-0-do-php/
Sample of how convert non-specific-third party web-services to mwsx
"sheets" folder:
correios.mwsd
gmaps.mwsd
aws.mwsd
facebook.mwsd
twitter.mwsd
allow user to re-write mwsd links (like ruby or codeIgniter routing):
<?php
$routing = array(
'(:any).php?mwsd' => '$1/mwsd',
'(:any)/(:any).php?mws=sum&a=(:any)&b=(:any)' => '$1/ws/$2/sum/$3;$4'
);
We need to handle other XMLHttpRequest events like cancel or abort. The user can pass an callback function to be called when theses events ocour
Test file upload in browsers that support FormData class. This already implemented, but we need test.
Enhancement: User can pass a callback function to control the progress of upload.
modify mwsx.js:
http_read(url, post_data, callback): insert callback_progress
We need a new, stunning page to show all the mwsx possibilities. This page must explain how to install / use, what is mwsx, and sample uses like an "mwsx hello world", ajax file upload, ajax autosuggest, and integrations with real-world apps like twitter, gmaps, facebook, aws, etc.
We need explain all the "drug interactions" good and bad.
We need a video to explain all this, and how to improve and participate the project, and live samples, and a big button to download the last version (production minified, production-normal, and nightly build).
re-organize the php code:
create an "ws_include", to behave similar to "include" of PHP (PHP and JS clients). With this function, we can add functions of an ,mwsx server and use-it like a local library
I believe that this will be an "wow factor" to new users
JS:
function ws_include(url)
{
var ws = ws(url);
for(var i in ws) {
this.ws[i].name = ws[i];
}
}
ws_include('http://an-mwsd-url.com');
alert(soma(1,2));
not detecting functions that arguments definition have a newline (\n) between it
Create a ZIP package with a fully-functional samples
we need add support to more languages, like: Ruby, Perl, Java, node.js, Delphi, VB.net, ASP, JSP, Python, C, shell script, and many others, but we will prior the top languages to achieve a high audience.
In this url we see the top ten languages:
https://github.com/languages
So, the next language will be the popular Ruby. Basically we will port the php client/server to Ruby and test the interoperability: Ruby / PHP -> Ruby / PHP / JS
this lib it's Varnish compatible?
We need a mwsx version in jQuery plugin format. This will be: jquery-mwsx.js and will behave similar to native jquery ajax feature: $.mwsx
Advogate to turn mwsx into a native feature
optimize client connections with "CURLOPT_WRITEFUNCTION". We can call mwsd asynchronously and when we call a function, wait util receive mwsd back.
if possible, don't use eval (ws_include() and ws()). Instead create a temporary file and include it. If file was already create, just include it, don't need to create again. If APC is enabled, this will be cached automatically.
PS: don't use a real tmp file, use a php wrapper.
PS 2: some systems don't allow create temporary files, if so, use eval.
Internal vars/functions like published_functions() or $ws_result should'n be acessible. We should create an mwsx class and protect this methods/attributes
class mwsx {
private function published_functions();
...
}
mwsx = new mwsx();
function ws($url) {return mwsx.ws($url);}
3 cache options: none, file or memcached
If user choose "file", we'll save/load in a temporary directory (same session path) or at user-defined file.
WARNING: this can potentially open a security threat: "mwsd poisoning"
avoid library conflicts with namespaces:
user config-file, so we don't need change the library file (mwsx.php). We'll use "parse_ini_file" function to extract data.
Ex.:
[cache]
cache_mode = memcached; # values can be off / memcached / file
cache_memcached_host = "host:port";
cache_timeout = 60; # value in seconds (or if change inode / file-timestamp)
[routing]
(:any).php?mwsd = $1/mwsd,
(:any)/(:any).php?mws=sum&a=(:any)&b=(:any) = $1/ws/$2/sum/$3;$4
Use of memchaced for speedup mwsd (php server side)
in mwsx.php or user-file:
<?php
$mwsx_config = array("host_memcache" => "host:port");
?>
in mwsx.php, function "show_mwsd", insert something like this:
<?php
if (isset($mwsx_config["host_memcache"]))
{
$key = md5($my_url)
$mem = new Memcache;
$mem->addServer($mwsx_config["host_memcache"]);
$mwsd = $mem->get($key);
if ($mwsd === false)
{
$mwsd = show_mwsd();
$mem->set($key, $mwsd, 0, $mwsx_config["cache_expire"]);
}
}
else {
$mwsd = show_mwsd();
}
?>
não funciona com links https para ler o mwsd
Translate and fix comments in english
besides the memcached cache, allow APC cache
use APC bytecode cache function to minimize resource consumption at function on-the-fly creation (ws_include or ws).
Use a wrapper, not a real file with "php://temp" or "php://memory"
look at:
http://php.net/manual/en/wrappers.php.php
Proccess:
ws_include: relative URL doesn't work with https
sometimes we have 2 include files with the same name functions. Ex.: we have a "user.php" include file with the function "new()", and want include "book.php" file which has your own "new()" function. Today this will generate a "cannot redeclare new function" error. In this proposal, we can change the name of function at include time, adding a prefix. We'll change the include_ws function from this:
include_ws($url)
to this:
include_ws($url [, $prefix])
Ex.:
include_ws("my_user_mwsd_url", "user_");
include_ws("my_book_mwsd_url", "book_");
this will produce "user_new()" and "book_new()" functions, avoiding name conflicts. Another product will be "user_::new()" and "book_::new()" (aka called Paamayim Nekudotayim)
PS: in this example if you use Paamayim Nekudotayim don't add underscore, it's ugly ;)
its interesting to use websockets for something?
one possible use:
in js, publish some javascript functions, save "url" of local javascript in server-side session. Then, in PHP (or other server), bind with "require_ws($SESSION['js_ws'])".
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.