Symfony 4: A quick Demo

Creating a new Project

The first step is to create a project. Currently, this needs to be done via composer create-project. We might release a tool to bootstrap a project faster.

composer create-project "symfony/skeleton:^3.3" demo
cd demo
git init
git add .
git commit -m "initial set of files"
###> symfony/framework-bundle ###
APP_ENV=dev
APP_DEBUG=1
APP_SECRET=ODtvoHW6pn3bE2rHgTa2MjkjwefzlsJH
###< symfony/framework-bundle ###
return [
'Symfony\Bundle\FrameworkBundle\FrameworkBundle' => ['all' => true],
];
composer req webserver
composer req cli
composer req cli:next
composer rem cli
composer req admin
<?phpnamespace App\Entity;use Doctrine\ORM\Mapping as ORM;/**
* @ORM\Entity
* @ORM\Table(name="product")
*/
class Product {
/**
* @ORM\Column(type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
public $id;
/**
* @ORM\Column(type="string", length=100)
*/
public $name;
/**
* @ORM\Column(type="decimal", scale=2)
*/
public $price;
/**
* @ORM\Column(type="text")
*/
public $description;
}
###> doctrine/doctrine-bundle ###
DATABASE_URL=mysql://root@127.0.0.1:3306/symfony?charset=utf8mb4
###< doctrine/doctrine-bundle ###
./bin/console doctrine:database:create
./bin/console doctrine:schema:update --force
easy_admin:
entities:
- App\Entity\Product
Symfony Flex in action to create an API project
  • sec-checker to install the SensioLabs Security Checker;
  • req-checker to install the Symfony requirements checks;
  • log to install MonologBundle and all its dependencies;
  • template for Twig;
  • mailer for Swiftmailer;
  • profiler for the profiler;
  • … you get the point :)

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Fabien Potencier

Fabien Potencier

9.7K Followers

founder and CEO @SensioLabs and @blackfireio, founder and project lead @Symfony