PHP Classes

Simple PHP Framework Application: Example MVC application with the Symfony framework

Recommend this page to a friend!
     
  Info   Example   View files Files   Install with Composer Install with Composer   Download Download   Reputation   Support forum   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2023-11-25 (10 months ago) RSS 2.0 feedNot yet rated by the usersTotal: 39 All time: 10,910 This week: 66Up
Version License PHP version Categories
simple-php-framework 1.0The PHP License7Libraries, Design Patterns, PHP 7, Ap...
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

Picture of Nahidul Hasan
  Performance   Level  
Name: Nahidul Hasan <contact>
Classes: 16 packages by
Country: Bangladesh Bangladesh
Age: ???
All time rank: 257332 in Bangladesh Bangladesh
Week rank: 170 Up2 in Bangladesh Bangladesh Up
Innovation award
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


  Files folder image Files (23)  
File Role Description
Files folder imageConfig (1 file)
Files folder imagedocker (2 directories)
Files folder imagesrc (1 file, 6 directories)
Files folder imagetests (1 directory)
Files folder imageweb (1 file)
Accessible without login Plain text file composer.json Data Auxiliary data
Accessible without login Plain text file composer.lock Data Auxiliary data
Accessible without login Plain text file docker-compose.yml Data Auxiliary data
Accessible without login Plain text file phpunit.xml.dist Data Auxiliary data
Accessible without login Plain text file README.md Doc. Documentation
Accessible without login Plain text file test.php Test Unit test class using PHPUnit

  Files folder image Files (23)  /  Config  
File Role Description
  Accessible without login Plain text file api.php Aux. Auxiliary script

  Files folder image Files (23)  /  docker  
File Role Description
Files folder imagenginx (1 file)
Files folder imagephp (2 files)

  Files folder image Files (23)  /  docker  /  nginx  
File Role Description
  Accessible without login Plain text file default.conf Data Auxiliary data

  Files folder image Files (23)  /  docker  /  php  
File Role Description
  Accessible without login Plain text file custom.ini Data Auxiliary data
  Accessible without login Plain text file Dockerfile Data Auxiliary data

  Files folder image Files (23)  /  src  
File Role Description
Files folder imageAPI (1 directory)
Files folder imageCalendar (2 directories)
Files folder imageContracts (1 file)
Files folder imageHelper (1 file)
Files folder imageServices (3 files)
Files folder imageSimplex (1 file)
  Accessible without login Plain text file routes.php Example Example script

  Files folder image Files (23)  /  src  /  API  
File Role Description
Files folder imageController (2 files)

  Files folder image Files (23)  /  src  /  API  /  Controller  
File Role Description
  Plain text file APIController.php Class Class source
  Plain text file HomeController.php Class Class source

  Files folder image Files (23)  /  src  /  Calendar  
File Role Description
Files folder imageController (1 file)
Files folder imageModel (1 file)

  Files folder image Files (23)  /  src  /  Calendar  /  Controller  
File Role Description
  Plain text file LeapYearController.php Class Class source

  Files folder image Files (23)  /  src  /  Calendar  /  Model  
File Role Description
  Plain text file LeapYear.php Class Class source

  Files folder image Files (23)  /  src  /  Contracts  
File Role Description
  Plain text file OutPutInterface.php Class Class source

  Files folder image Files (23)  /  src  /  Helper  
File Role Description
  Plain text file Config.php Class Class source

  Files folder image Files (23)  /  src  /  Services  
File Role Description
  Plain text file JsonOutputService.php Class Class source
  Plain text file TwitterAPIService.php Class Class source
  Plain text file TwitterHelperService.php Class Class source

  Files folder image Files (23)  /  src  /  Simplex  
File Role Description
  Plain text file Framework.php Class Class source

  Files folder image Files (23)  /  tests  
File Role Description
Files folder imageSimplex (1 directory)

  Files folder image Files (23)  /  tests  /  Simplex  
File Role Description
Files folder imageTests (1 file)

  Files folder image Files (23)  /  tests  /  Simplex  /  Tests  
File Role Description
  Plain text file FrameworkTest.php Class Class source

  Files folder image Files (23)  /  web  
File Role Description
  Accessible without login Plain text file index.php Example Example script

The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page.
Install with Composer Install with Composer
 Version Control Unique User Downloads Download Rankings  
 100%
Total:39
This week:0
All time:10,910
This week:66Up