Symfony Flex: Paving the Path to a Faster, Better Symfony

Symfony Flex: Paving the Path to a Faster, Better Symfony



Still Under Development

Survey result

What’s Different?

Bootstrapping

 composer create-project symfony/skeleton flexy
Directory structure
index:
    path: /
    defaults: { _controller: 'App\Controller\DefaultController::index' }
<?php

namespace App\Controller;
use Symfony\Component\HttpFoundation\Response;

class DefaultController
{
    public function index()
    {
        return new Response('Hello');
    }
}
Hello Symfony

Execution Permissions

~ bin/console
-bash: bin/console: Permission denied

Adding Bundles

composer req template
{% extends '../base.html.twig' %}

{% block body %}
    {{ greeting }}
{% endblock %}
<?php

namespace App\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\Controller;

class DefaultController extends Controller
{
    public function index()
    {
        return $this->render('default/index.html.twig', ['greeting' => 'hello']);
    }
}
Screenshot of templated view

Big Bundles

composer req admin
mysql -u homestead -psecret
create database flexy character set utf8mb4 collate utf8mb4_unicode_ci;
DATABASE_URL="mysql://homestead:secret@127.0.0.1:3306/flexy?charset=utf8mb4&serverVersion=5.7"
<?php


namespace App\Entity;
use Doctrine\ORM\Mapping as ORM;

/**
 * Class Submission
 * @package App\Entity
 *
 * @ORM\Entity
 * @ORM\Table(name="submission")
 */
class Submission
{
    /**
     * @ORM\Column(type="integer")
     * @ORM\Id
     * @ORM\GeneratedValue(strategy="AUTO")
     */
    public $id;

    /**
     * @ORM\Column(type="string", length=255)
     */
    public $name;

    /**
     * @ORM\Column(type="string", length=255)
     */
    public $url;

    /**
     * @ORM\Column(type="text")
     */
    public $description;
}
easy_admin:
    entities:
        - App\Entity\Submission
bin/console doctrine:schema:update --force
Easy Admin Bundle Back End Screen
A submission was added

Unofficial Bundles

composer config extra.symfony.allow-contrib true
composer req ramsey/uuid-doctrine
A warning about the contrib recipe
doctrine:
    dbal:
        url: '%env(DATABASE_URL)%'
        types:
            uuid:  Ramsey\Uuid\Doctrine\UuidType
    orm:
    ...
...
class Submission
{
    /**
     * @var \Ramsey\Uuid\Uuid
     *
     * @ORM\Id
     * @ORM\Column(type="uuid", unique=true)
     * @ORM\GeneratedValue(strategy="CUSTOM")
     * @ORM\CustomIdGenerator(class="Ramsey\Uuid\Doctrine\UuidGenerator")
     */
    public $id;
...
bin/console doctrine:schema:drop --force
bin/console doctrine:schema:update --force
New entity added

Adding Third Party Tools

Conclusion

Comments

Popular posts from this blog

A Tailwind CSS Preset for Laravel 5.5

Short and safe array iteration

PHPStorm's performance