1. Go to this page and download the library: Download weeger/wjs library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
weeger / wjs example snippets
$wjs = new Wjs();
// Add only option that you explicitly need,
// any option are version (minified),
// Accepts also "jQuery" or "source" for debug mode.
'subversion' => $subversion,
// Response path define the URL used by AJAX
// to retrieve extensions on your server, you
// obviously need to handle the path on server
// side, see bellow.
'clientPathResponse' => $yourCustomResponsePath,
// If you want to use static cache, you have
// to specify route for the local directory,
// it will be filled by all aggregated javascript and responses.
'serverPathCache' => $yourCustomCacheDirectory,
// Caching will generate aggregated javascript
// file and will place it into given directory
// according to pushed data for requested url.
'staticFilesEnabled' => $staticFilesEnabled,
// Force to regenerate existing files.
'staticFilesFlush' => $staticFilesFlush,
// Allow to merge all preloaded extensions
// and core js files into one js file.
'aggregationEnabled' => $aggregationEnabled,
'aggregationFlush' => $aggregationFlush,
// You can specify a file for main
// javascript file for complete page rendering,
// All files will be aggregated into one file,
// remember that this file content can completely change
// from one page to another, so think to name it accordingly.
'aggregationFileName' => $yourCustomCacheFileName,
// You can also specify a extra string
// for cache files naming. Useful to enforce
// to flush browsers caches.
'cacheToken' => $yourCustomCacheToken,
'paramInc' => 'wjs-test'
));
// Retrieve list of files used by core
$files = $wjs->jsFiles();
$wjs->response($_GET);
// Think about always make some verification on requested content.
if (isset($_GET['wjs']['JsArray']) && $_GET['wjs']['JsArray'] === 'myJsArrayName') {
// Manage which data to retrieve.
$wjs->import('JsArray', 'myJsArrayName');
// When response is ready to be sent,
// this function will add json headers,
// print package content, then exit.
$wjs->response();
}
// Add a remote file.
$this->wjs->extensionAdd('JsScript', 'testScriptFile', $filePath);
// Add an inline code.
$this->wjs->extensionAdd('JsScript', 'testScriptInline', 'window.jsScriptInlineLoaded = true;');
// Add reloadable script,
// it will increment global var at each pull, with the reload:true option.
$this->wjs->extensionAdd('JsScript', 'jsScriptReloadable', 'window.jsScriptReloadCount===undefined ? window.jsScriptReloadCount = 0 : window.jsScriptReloadCount++;');
// Add javascript method from a file.
$this->wjs->extensionAdd('JsMethod', 'testMethod', $path);
[PULL_WJSLOADER_PHP]
// Extension of type JsObject > testObject,
// will be loaded with JsObject > testObject2 when asked.
$this->wjs->extensionAddRequire('JsObject', 'nameOfJsObjectWithDependencies', 'JsObject', 'nameOfJsObjectWithDependencies2');
javascript
new WjsProto( print $wjs->initPackage();
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.