Get Started - aPisC/phroper GitHub Wiki

Install

You can install phroper in your project with composer, this command will install the base engine. Don't forget to require the composer autoload script at the forst line of your php code.

composer require apisc/phroper

Url rewrite

To handle all incoming request with the same configuration properly, you have to rewrite the url to a specified php file (for example: index.php). In Apache you have to enable rewrite module and place a .htaccess file in the root of the application. The original url will be passed in __url__ option.

RewriteEngine On
RewriteRule ^([^?]*) index.php?:__url__=$1 [L,QSA]

<Limit GET POST PUT OPTIONS DELETE>
    Require all granted
</Limit>
<LimitExcept GET POST PUT OPTIONS DELETE>
    Require all denied
</LimitExcept>

Phroper initialization

In the index.php file call the static initialize function of the Phroper class. After initialized the engine, you can register other packages, that are based on Phroper, and the last step is to call the run function to handle the request with Phroper.

Example of index.php:

require __DIR__ . '/vendor/autoload.php';
use Phroper\Phroper;

Phroper::initialize([
    "ROOT" => __DIR__,
    "API_URL" => "/api",
    "MYSQLI" => new mysqli(/* ... */),
    "CONFIG_FILE" => __DIR__ . "/config.php"
]);

// Register other components to Phroper here

Phroper::run();

Database initialization

Phroper is able to create the required database tables, visit the /api/init/all url, to start the initialization. The databaseused by phroper have to exist before the initialization process.

⚠️ **GitHub.com Fallback** ⚠️