1. Go to this page and download the library: Download cammanderson/phruts 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/ */
cammanderson / phruts example snippets
// web/index.php
HttpFoundation
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\HttpKernelInterface;
// Create a silex application
$app = new Silex\Application();
// Add in Twig as the template handler
$app->register(new Silex\Provider\TwigServiceProvider(), array('twig.path' => __DIR__.'/../app/Resources/views'))
->register(new Silex\Provider\MonologServiceProvider(), array('monolog.logfile' => __DIR__.'/../app/logs/development.log'));
// Add in phruts to organise your controllers
$app->register(new Phruts\Provider\PhrutsServiceProvider(), array(
// Register our modules and configs
Phruts\Util\Globals::ACTION_KERNEL_CONFIG => array(
'config' => '../app/config/web-config.xml', // Supports multiple modules/configurations
)
));
// Add template handling for matching forwards to Twig templates
$app->get('{path}', function($path) use ($app) {
return $app['twig']->render($path);
})
->assert('path', '.+\.twig');
// Add routes to be matched by Phruts
$app->get('{path}', function (Request $request) use ($app) {
return $app[\Phruts\Util\Globals::ACTION_KERNEL]->handle($request, HttpKernelInterface::SUB_REQUEST, false);
})
->assert('path', '.*')
->value('path', '/'); // Set the welcome path
$app->run();
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.