Skip to content
This repository has been archived by the owner on Feb 16, 2022. It is now read-only.

Usage with Others

TheUltraGrey edited this page Feb 6, 2017 · 1 revision

Using Web Composer with other frameworks

Installation

First we begin by installing the library using composer -locally if you don't have shell access- as follows:

composer require grey-dev-0/web-composer

Configuration

After composer downloads the library you can find all configuration values in a smarty config file located in /vendor/grey-dev-0/web-composer/views/smarty/config/master.conf and, the settings are:

  • baseUrl is the full URL of the library after it's been downloaded so you have to replace theultragrey.greydev segment of the URL with your own domain name.
  • appUrl is the full URL of your project's homepage.
  • title is the Title shown on the library's views.
  • appKey is the key used to protect intrusions for background tasks of the library it's recommended to change its value to something else.
  • prefix is the URL prefix segment that will allow access to the library's views by default it's accessed on http://your_domain/smarty-composer so if you'd like to change that smarty-composer to something else you can by setting this value.
  • cacheDir is the directory where the integrated composer library stores packages data, please set this value to a writable directory on server.

Usage

In your handling php script file just add the following lines before your script:

require_once __DIR__.'/vendor/autoload.php';
new \GreyDev\WebComposer\WebComposer::init();

That's it, you're good to go, you can initialize the library whenever you like of course, but if you do it this way the library will check the requested URL and if it matches one of its routes it will replace your webpages with its own. And it is recommended to initialize the library after an authentication mechanism to avoid end-users or outsiders from using the library.

Note: the require_once above assumes that your script is located in the same directory where vendor directory is created, if it's saved in a different location please change the location of that require_once statement accordingly.

The library has two main views installed packages and, all packages, the first can be used to update or remove one of the packages you have installed in your project, and the latter will enable you to install new packages with the version you choose. And both views include a console output at the bottom that shows progress and details of any operations you'd request.

Note about Web Composer's console

The console at the bottom of the page is not synchronized with the operations handled on server in real time and, there is a continuous sync function that runs when any operation is requested e.g. a new package install, and there is a switch button beside the console button that toggles that function on and off, so if there is a background operation running and the sync function isn't working you can switch it on by clicking that button, and if you've requested an operation and don't like that sync function to bother the server with repetitive requests you can switch it off using the same button.