- FEATURES
- Autoload
- Class Reflection
- Magic Methods
- Exceptions
- Late Static Binding
- Type Hinting
- SPL
- PHPUNIT
- PHAR
- COMPOSER
- Carbon
- Guzzle
- Faker
- Math
- Requests
- DESIGN PATTERNS
- Singleton Pattern
- Observer Pattern
- Strategy Pattern
- Dependency Injection
- Middleware
- Registry
- SYMFONY
- Routes
-
Annotations
- Flex
- Controllers
- Doctrine
- Templating
- VERSIONS
- Php7.4
- Php8.0
- SECURITY
- Filter Input
- Remote Code Injection
- Sql Injection
- Session Fixation
- File Uploads
- Cross Site Scripting
- Spoofed Forms
- CSRF
- Session Hijacking
- MODERN PHP
- Composer
- Autoloader
- Package
- Releases
- Generators
- Dependency Injection
- Middleware
- CUSTOM FRAMEWORK
- App
- Http Foundation
- Front Controller
- Routing
- Render Controller
- Resolver
- SoC
- FRAMEWORKS
- Slim
- Symfony V5
- Laravel V8
- Laminas V3
- Codeigniter V4
Annotations
Create a skeleton project and install annotations package.
composer create-project symfony/skeleton annotations
cd annotations/
composer require annotations
symfony server:start
http://localhost:8000
# Welcome to Symfony
Controller
Routes and methods live in the same file, in controller.
/**
* Default Controller
*
* src/Controller/DefaultController.php
*
* Annotation adds route above method ...
* config/routes.yaml not neeeded.
*
* http://localhost:8000/default/ # Index page
* http://localhost:8000/default/hello # Hello world
* http://localhost:8000/default/page/3 # Page 3
*
*/
namespace App\Controller;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
/**
* @Route("/default")
*/
class DefaultController
{
/**
* @Route("/")
*/
public function index()
{
return new Response("Index page");
}
/**
* @Route("/hello/{name}", defaults={"name"="world"})
*/
public function hello($name)
{
return new Response("Hello $name");
}
/**
* @Route("/page/{id}", name="page", requirements={"id"="\d+"})
*/
public function page($id)
{
return new Response("Page $id");
}
}
Last update: 531 days ago