Laravel is a free, open-source PHP web application framework, created by Taylor Otwell and intended for the development of web applications following the model–view–controller (MVC) architectural pattern -- source.
###Pre-requisites
- Make sure you have installed PHP version >= 5.5.9
- You should also have OpenSSL PHP, PDP PHP, Mbstring PHP and Tokenizer PHP extensions but these might come anyway.
Using this makes it much easier to install the remaining components. Go here and choose the installer that matches your system. Once installed, check it is working with:
> composer
This only needs to be run once.
> composer global require "laravel/installer"
Pay attention to where it is installed in the user output that is produced -- it should be somewhere like ...vendor/bin. If you can't see anything, take a look in a folder which resembles C:\Users[name]\AppData\Roaming\Composer and you should see the vendor folder there.
Could be useful :-) Make sure npm and node.js are installed first, though.
> npm install -g gulp
> php artisan --version
> php artisan list
> laravel new <project-name>
> php artisan help <command>
e.g.
> php artisan help make:controller
> php artisan serve
and then go to (usually) http://localhost:8000
> php artisan make:migration [name] --create=notes
Where name could be something like "create_notes_table" and instead of notes, you would use your table name.
> php artisan migrate
``
### Rolling back a migration
php artisan migrate:rollback
### Undoing a whole migration and re-doing it
php artisan migrate: fresh
### Running Tinker
php artisan tinker
### Making a model
php artisan make:model [name]
Where name is the name of the model/class. Add "-m" to make the migration, too.
### Database manipulations in Tinker
App\User::all();
App\Note::find(6);
App\Note::find(6)->delete();
### Show full debugging in browser
Go to app\config\app.php and set this line to true:
'debug' => env('APP_DEBUG', true),
### Faking unimplemented REST methods
> php artisan key:generate
In config\app.php, ensure this has the following line:
'key' => env('APP_KEY','MF5l...'),
'cipher' => 'AES-256-CBC',
Where the MF51 part came from the artisan command above. This is needed if you see an error like this:
RuntimeException in compiled.php line 7530:
No supported encrypter found. The cipher and / or key length are invalid.
All form elements should use the following:
<form....>
{{ csrf_field() }}
Another way, rather like removing a limb to fix an itch, is this: Edit App\Http\Kernel.php as follows:
protected $middlewareGroups = [
'web' => [
\App\Http\Middleware\EncryptCookies::class,
\Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
\Illuminate\Session\Middleware\StartSession::class,
\Illuminate\View\Middleware\ShareErrorsFromSession::class,
// \App\Http\Middleware\VerifyCsrfToken::class,
Although this absolutely isn't the right way :-)
{{ var_dump($errors) }}
Written by Stephen Moon ([email protected]), 2016