Laravel Homestead

Updated: 06 May 2024

IP address of host from inside of Homestead: 10.0.2.2


Connect via ssh, from the Homestead directory

vagrant ssh

Run composer with php version 7.2

php7.2 /usr/local/bin/composer update

Reset to original state

vagrant destroy --force && vagrant up

Reload

vagrant reload --provision

Check which PHP versions have xdebug enabled

phpquery -v 5.6 -s fpm -m xdebug
phpquery -v 7.0 -s fpm -m xdebug
phpquery -v 7.1 -s fpm -m xdebug
phpquery -v 7.2 -s fpm -m xdebug
phpquery -v 7.3 -s fpm -m xdebug
phpquery -v 7.4 -s fpm -m xdebug
phpquery -v 8.0 -s fpm -m xdebug
phpquery -v 8.1 -s fpm -m xdebug
phpquery -v 8.2 -s fpm -m xdebug
phpquery -v 8.3 -s fpm -m xdebug

Enable the Xdebug module for the fpm SAPI of PHP version 5.6

phpenmod -v 5.6 -s fpm -m xdebug

Symfony testing

Updated: 04 April 2024

Testing (Symfony Docs)

Unit Tests

These tests ensure that individual units of source code (e.g. a single class or a method in a class) behave as intended. No different from writing standard PHPUnit unit tests.

Integration Tests

These tests test a combination of classes and commonly interact with Symfony’s service container. These tests do not yet cover the fully working application.

Application Tests

Verify the behavior of a complete application. They make HTTP requests (both real and simulated ones) and test that the response is as expected.

The output of the make:test command supplies a useful summary too

root@5b8333e33939:/var/www/html# bin/console make:test

 Which test type would you like?:
  [TestCase       ] basic PHPUnit tests
  [KernelTestCase ] basic tests that have access to Symfony services
  [WebTestCase    ] to run browser-like scenarios, but that do nott execute JavaScript code
  [ApiTestCase    ] to run API-oriented scenarios
  [PantherTestCase] to run e2e scenarios, using a real-browser or HTTP client and a real web server
 >

Symfony console

Updated: 19 November 2024

Generate a migration by comparing your current database to your mapping information

doctrine:migrations:diff

Create a new migration based on database changes

make:migration

List all configured routes in application

bin/console debug:router

Display environment variables used in the container

bin/console debug:container --env-vars

Symfony – scaffold app from existing database

Updated: 04 April 2024

Prepare for a new run

rm -r src/Entity/*
rm -r src/Form/*
rm -r src/Controller/*
rm -r src/Repository/*
rm -r templates/*

Copy in a backup of base twig template

cp base.html.twig templates/

Generate entities from an existing database

bin/console doctrine:mapping:import "App\Entity" annotation --path=src/Entity
bin/console make:entity --regenerate App

Make CRUD for each new entity

bin/console make:crud MyEntity
bin/console make:crud AnotherEntity
...

Adjust file permissions

sudo chown -R chris:chris templates/
sudo chown -R chris:chris src/Entity/
sudo chown -R chris:chris src/Controller/
sudo chown -R chris:chris src/Form/

Now, sql insert data fixtures

...