- Php
- Features
- Autoload
- Class Reflection
- Magic Methods
- Exceptions
- Late Static Binding
- Type Hinting
- SPL
- PHPUNIT
- PHAR
- Composer
- Guzzle
- Carbon
- Faker
- Math
- Requests
- Design Patterns
- Singleton Pattern
- Observer Pattern
- Strategy Pattern
- 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
- Slim Framework
- Autoloader
- Package
- Releases
- Generators
- Dependency Injection
- Middleware
- Create Framework
- App
- Http Foundation
- Front Controller
- Routing
- Render Controller
- Resolver
- SoC
- Frameworks
- Symfony V5
- Laravel V8
- Laminas V3
- Codeigniter V4
Flex
Symfony Flex is a Composer plugin already installed with Symfony.
composer create-project symfony/skeleton flex
cd flex/
Recipe
# Twig is not the name of a Composer package (it is a Flex alias).
# Flex resolves that alias for Composer.
# Flex installs a recipe for symfony/twig-bundle.
# A recipe is a way for a library to automatically configure itself.
composer require twig
composer require profiler
composer require api
composer remove api
composer remove vendor/package
symfony server:start
http://localhost:8000 # Welcome to Symfony
Twig
Twig is a fast and secure template engine for PHP.
/**
* DefaultController
*
* src/Controller/DefaultController
*
* Starting from Symfony 5.0 support for PHP templates was removed.
* Only Twig templates can be used.
*
* http://localhost:8000/hello # Hello WORLD
* http://localhost:8000/hello/Symfony # Hello SYMFONY
*
*/
namespace App\Controller;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
class DefaultController extends AbstractController
{
/**
* @Route("/hello/{name}")
*/
public function hello($name='World')
{
return $this->render('default/index.html.twig', [
'name' => $name,
]);
}
}
Templates
Twig compiles templates down to plain optimized PHP code.
<!-- templates/default/index.html.twig -->
{% include 'header.html.twig' %}
<b>Hello name|upper</b>
Last update: 61 days ago