Last Updated | | Ratings | | Unique User Downloads | | Download Rankings |
2023-11-25 (1 month ago) | | Not yet rated by the users | | Total: 32 This week: 1 | | All time: 10,930 This week: 108 |
|
Description | | Author |
This package provides an example MVC application with the Symfony framework.
It defines routes to process HTTP requests using controllers defined using class files.
Currently, it provides controller classes for:
- Check if the current year is a leap year
- Show a dashboard on the home page
- Search for Twitter posts | |
|
|
Innovation award
Nominee: 7x |
|
Example
<?php
define('ROOT_DIR', realpath(__DIR__ . '/../'));
require_once __DIR__.'/../vendor/autoload.php';
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing;
use Symfony\Component\HttpKernel;
use Symfony\Component\HttpKernel\Controller\ArgumentResolver;
use Symfony\Component\HttpKernel\Controller\ControllerResolver;
function render_template(Request $request)
{
extract($request->attributes->all(), EXTR_SKIP);
ob_start();
include sprintf(__DIR__.'/../src/pages/%s.php', $_route);
return new Response(ob_get_clean());
}
$dotenv = new Dotenv\Dotenv(ROOT_DIR);
$dotenv->load();
$request = Request::createFromGlobals();
$routes = include __DIR__.'/../src/routes.php';
$context = new Routing\RequestContext();
$matcher = new Routing\Matcher\UrlMatcher($routes, $context);
$controllerResolver = new ControllerResolver();
$argumentResolver = new ArgumentResolver();
$framework = new Simplex\Framework($matcher, $controllerResolver, $argumentResolver);
$response = $framework->handle($request);
$response->send();
|
Details
simple-php-framework
Trying to develop basic framework structure using symfony component
Installation:
Clone the repo
Run the following command
composer update
Run the PHP built-in server (php >= 7.0):
php -S 127.0.0.1:4321 -t web/ web/index.php
Now browse the project
http://127.0.0.1:4321/is_leap_year/2020
For docker
Run the following command
docker-compose up -d
Now browse the project
http://127.0.0.1:8097/is_leap_year/2020
|
Applications that use this package |
|
No pages of applications that use this class were specified.
If you know an application of this package, send a message to the author to add a link here.