Get Started - aPisC/phroper GitHub Wiki
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
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>
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();
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.