Skip to content

Instantly share code, notes, and snippets.

@hex333ham
Last active June 25, 2019 13:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hex333ham/771e9ce1e13fe530916c698b997cc11b to your computer and use it in GitHub Desktop.
Save hex333ham/771e9ce1e13fe530916c698b997cc11b to your computer and use it in GitHub Desktop.
Symfony 4 cheat sheet

A cheat sheet of useful commands I keep updated to make my life easier.

Installation

https://symfony.com/doc/current/setup.html

New Project

composer create-project symfony/skeleton [PROJECT NAME]

Setup for Apache

https://symfony.com/doc/current/setup/web_server_configuration.html

Run recipe to make subdir/alias work

Check Version

php bin/console --version

Clear Cache

php bin/console cache:clear --no-warmup --env=prod

Help

php symfony

Run Server

php bin/console server:run

Or while using the Symfony client:

symfony server:start

View here - http://127.0.0.1:8000/

Testing (Unit & Functional)

php bin/phpunit

https://symfony.com/doc/current/testing.html

Test Error Pages

https://symfony.com/doc/current/controller/error_pages.html

http://localhost/_error/{statusCode}

http://localhost/_error/{statusCode}.{format}

Generators

Generate Bundle Wizard

php bin/console generate:bundle

Add to psr-4 autoload, then run:

composer dump-autoload

Generate Entity Wizard

https://symfony.com/doc/current/doctrine.html#creating-an-entity-class

php bin/console make:entity

Generate Controller Wizard

https://symfony.com/doc/current/doctrine.html#persisting-objects-to-the-database

php bin/console make:controller ProductController

Generate Form From Entity

php bin/console generate:doctrine:form [BUNDLE NAME]:[ENTITY NAME]

Doctrine and migration (update DB)

http://symfony.com/doc/current/doctrine.html

Migration

php bin/console doctrine:migrations:diff
php bin/console doctrine:migrations:migrate

Migrating up/down

php bin/console doctrine:migrations:execute YYYYMMDDHHMMSS  --up
php bin/console doctrine:migrations:execute YYYYMMDDHHMMSS  --down

Create DB

php bin/console doctrine:database:create

Drop DB

php bin/console doctrine:database:drop --force

Debug

php bin/console debug:router

FOSuserbundle

https://symfony.com/doc/current/bundles/FOSUserBundle/index.html

CLI

http://symfony.com/doc/master/bundles/FOSUserBundle/command_line_tools.html

Installation

https://symfony.com/doc/master/bundles/FOSUserBundle/index.html

Override Default Templates

https://symfony.com/doc/current/bundles/FOSUserBundle/overriding_templates.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment