Skip to content

Instantly share code, notes, and snippets.

@ederrafo
Last active August 28, 2018 22:33
Show Gist options
  • Save ederrafo/8a64c2723aae8eace3b691455145b4fe to your computer and use it in GitHub Desktop.
Save ederrafo/8a64c2723aae8eace3b691455145b4fe to your computer and use it in GitHub Desktop.
commands symfony 2
Create new project
$ symfony new my-project 2.8.0
or
$ symfony new my-project lts
or
$ composer create-project symfony/framework-standard-edition my_project_name "2.8.*"
Check version Symfony
$ php app/console --version
or
$ php bin/console --version
Running the symfony application
$ php app/console server:run
Multiple connections
# play only with "customer" mappings
$ php app/console doctrine:database:create --connection=customer1
Assets Install
# make a hard copy of the assets in web/
$ php app/console assets:install
# if possible, make absolute symlinks in web/ if not, make a hard copy
$ php app/console assets:install --symlink
# if possible, make relative symlinks in web/ if not, make a hard copy
$ php app/console assets:install --symlink --relative
Create un usuario
$ php app/console fos:user:create admin [email protected] --super-admin
SONATA-ADMIN
Esta libreria le da estilo al admin de Sonata
$ composer require jms/serializer-bundle ^1.1
Enable the translator in your configuration:
# app/config/config.yml
framework:
translator: { fallbacks: [en] }
fuentes para el proyect
http://stackoverflow.com/questions/16993733/sonata-admin-bundle-one-to-many-relationship-not-saving-foreign-id
composer require sonata-project/media-bundle
Extend the Bundle
$ php app/console sonata:easy-extends:generate SonataUserBundle -d src
$ php app/console sonata:easy-extends:generate SonataMediaBundle -d src
$ php app/console sonata:easy-extends:generate SonataClassificationBundle -d src
$ php app/console sonata:easy-extends:generate SonataDoctrineORMAdminBundle -d src
After in AppKernel.php
new Application\Sonata\DoctrineORMAdminBundle\ApplicationSonataDoctrineORMAdminBundle()
Install Symfony installer, Linux and macOS systems
$ sudo curl -LsS https://symfony.com/installer -o /usr/local/bin/symfony
$ sudo mkdir -p /usr/local/bin
$ sudo chmod a+x /usr/local/bin/symfony
Create new project
$ symfony new my-project 2.8
Create Bundle
$ php app/console generate:bundle --namespace=Ens/JobeetBundle --format=yml
$ php app/console generate:bundle --namespace=JobBundle --format=yml
Generate Entity
$ php app/console generate:doctrine:entity --no-interaction --entity=AssociationMappingBundle:Participant
Generate entities from existing DB model, methods setter and getters for specific Entity in Bundle
$ php app/console doctrine:generate:entities FormsMobilityBundle:Mobility
Clear cache
$ php app/console cache:clear --env=prod
$ php app/console cache:clear --env=dev
View routes in project
$ php app/console debug:router
View routes only contains API
$ php app/console debug:route | grep api
Load Data fix in database
$ php app/console doctrine:fixtures:load
Load Data fix per Bundle
$ php app/console doctrine:fixtures:load --fixtures=src/FormsMobilityBundle/DataFixtures/ORM
Create Controller's
$ php app/console doctrine:generate:crud --entity=EnsJobeetBundle:Job --route-prefix=ens_job --with-write --format=yml
The Stylesheets, Images, and JavaScripts
http://www.ens.ro/downloads/jobeet-images.zip
http://www.ens.ro/downloads/jobeet-css.zip
$ php app/console assets:install web
Debug router
$ php app/console debug:router
$ php app/console debug:router route_job_show
To tell Symfony to make them available to the public.
$ php app/console assets:install web
Doctrine can generate the repository class for you by running the generate:entities command used earlier:
$ php app/console doctrine:generate:entities JobBundle
Create database
$ php app/console doctrine:database:create
Doctrine to create our database tables (or to update them to reflect our setup) with the command:
$ php app/console doctrine:schema:update --force
$ php app/console doctrine:schema:update --force --em=default
Shows sql needed to update database model from entities.
$ php app/console doctrine:schema:update --dump-sql
Shows the status of migrations - which version is current,how many versions is behind and in front of current version.
$ php app/console doctrine:migrations:status
Applies all migration versions (by their order) which are in front of current version.
$ php app/console doctrine:migrations:migrate
Makes migration version based on current state of entities and current state of database.
$ php app/console doctrine:migrations:diff
Execute a single migration (defined by its number) up or down manually.
$ php app/console doctrine:migrations:execute --down 20150629191737
Load data
$ php app/console doctrine:fixtures:load
See it in Action in the Browser
$ php app/console doctrine:generate:crud --entity=EnsJobeetBundle:Job --route-prefix=ens_job --with-write --format=yml
dumps a MySQL database table for backup. Useful to see SQL statements which represent current database state.
$ mysqldump -t -u userName -ppassword dbName tableName
phpunit -c app src/AppBundle/Tests/Entity/RoleRepositoryFunctionalTest.php
$ runs phpunit tests
==== clonar un proyecto ====
$ git clone [email protected]:ederrafo/php-sf2-jobeet.git jobeet
Install Composer
$ curl -sS https://getcomposer.org/installer | php
$ mv composer.phar /usr/local/bin/composer
$ composer install
sources:
https://www.sgalinski.de/typo3-agentur/technik/how-to-create-a-symfony-2-project/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment