1. Go to this page and download the library: Download headio/phalcon-bootstrap 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/ */
/**
* This source file is subject to the MIT License.
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this package.
*/
declare(strict_types=1);
namespace Foo\Service;
use Foo\Exception\OutOfRangeException;
use Phalcon\Config\Config;
use Phalcon\Di\ServiceProviderInterface;
use Phalcon\Di\DiInterface;
use Phalcon\Cli\Router as CliService;
use Phalcon\Mvc\Router as MvcRouter;
use Phalcon\Mvc\Router\Annotations as MvcService;
class Router implements ServiceProviderInterface
{
/**
* {@inheritDoc}
*/
public function register(DiInterface $di) : void
{
$di->setShared(
'router',
function () use ($di) {
$config = $di->get('config');
if ($config->get('cli')) {
$service = new CliService();
$service->setDefaultModule($config->dispatcher->defaultTaskModule);
return $service;
}
if (!$config->has('modules')) {
throw new OutOfRangeException('Undefined modules');
}
if (!$config->has('routes')) {
throw new OutOfRangeException('Undefined routes');
}
$service = new MvcService(false);
$service->removeExtraSlashes(true);
$service->setDefaultNamespace($config->dispatcher->defaultControllerNamespace);
$service->setDefaultModule($config->dispatcher->defaultModule);
$service->setDefaultController($config->dispatcher->defaultController);
$service->setDefaultAction($config->dispatcher->defaultAction);
foreach ($config->get('modules')->toArray() ?? [] as $module => $settings) {
if (!$config->routes->get($module, false)) {
continue;
}
foreach ($config->get('routes')->{$module}->toArray() ?? [] as $key => $val) {
$service->addModuleResource($module, $key, $val);
}
}
return $service;
}
);
}
}
use Phalcon\Di;
use Foo\Bar\MyDi;
$config = new Config(
eate(new Di);
// Custom DI container
$di = (new DiFactory($config))->create(new MyDi);
/**
* This source file is subject to the MIT License.
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this package.
*/
declare(strict_types=1);
use Headio\Phalcon\Bootstrap\Application\Factory as AppFactory;
use Headio\Phalcon\Bootstrap\Di\Factory as DiFactory;
use Phalcon\Config\Config;
chdir(dirname(__DIR__));
ResponseInterface) {
return $response->send();
}
return $response;
} catch(\Throwable $e) {
echo $e->getMessage();
}