Laravel
composer create-project --prefer-dist laravel/laravel NAME
Vagrant
To start the server
vagrant up
To get inside the server
vagrant ssh
MySQL
Access mysql inside vagrant
// Passwrod secret
mysql -u homestead -p
Create database
// Passwrod secret
create database NAME
Artisan
See options
php artisan
See more info about a command
// php artisan help COMMAND
php artisan help make:controller
See Route list
php artisan route:list
Make controller
php artisan make:controller NAME
Database migration
php artisan make:migration create_todo_list_table --table=todo_lists
Run migration
php artisan migrate
Site setup
When SSH'ed into vagrant and in the 'Sites' folder, Install and create project with composer
composer create-project laravel/laravel auth --prefer-dist
Edit the homstead.yaml file, adding new site. Need to run 'vagrant provision' to update homestead.
- map: whatever.dev
to: /home/vagrant/Sites/whatever/public
Add line to hosts file
127.0.0.1 whatever.dev
Create controller(s)
php artisan make:controller NAME
Tie routes to the controller. If required can do a resource in the routes file to get a RESTful pattern
Route::resource('auth', 'authController');
Cross-site request forgery (CSRF)
Laravel automatically generates a CSRF "token" for each active user session managed by the application. This token is used to verify that the authenticated user is the one actually making the requests to the application.
<form method="POST" action="/profile">
@csrf
...
</form>