Laravel: Difference between revisions
No edit summary |
No edit summary |
||
| Line 1: | Line 1: | ||
== Installation == | == Installation == | ||
Download composer and create an alias so that `composer` launches composer: | |||
wget -O - https://getcomposer.org/installer | php -- --install-dir=$HOME/tmp/ | |||
alias composer='php $HOME/tmp/composer.phar' | |||
Set up the laravel project using composer: | |||
composer create-project laravel/laravel projectname --prefer-dist | composer create-project laravel/laravel projectname --prefer-dist | ||
There are many useful commands that comes with laravel's artisan command line PHP script located in the root of the project directory. You may want to create an alias for artisan: | |||
alias artisan='php artisan' | |||
The initial laravel project will come with scaffolding project files which you may want to remove by running: | |||
artisan fresh | artisan fresh | ||
Ensure that the webserver serving the laravel application has permission to write to the directories inside the `storagae` directory. If these directories are not writable by the webserver, no error messages will be displayed or logged. | |||
=== Troubleshooting === | |||
You can see what packages and dependencies were installed by running: | You can see what packages and dependencies were installed by running: | ||
composer show -i | composer show -i | ||
== Application == | |||
Most of your project files will end up inside the `app` and `resources` directory. | |||
=== Configuration === | |||
Configurations are defined inside the `.env` file located in the root directory of your laravel project. Variables defined in this file override any that are defined in the application configuration files and is the recommended way of setting values. | |||
=== Routing === | |||
All HTTP requests will go through to your `app/Http/` portion of your laravel project. | |||
== | === Models === | ||
Models are placed directly in the `app` directory and under the `App` namespace. When working with Models, reference them directly by their namespace or pull in the namespace. | |||
=== Views === | === Views === | ||
==== Forms ==== | ==== Forms ==== | ||
To use the Illuminate HTML package, pull in the `illuminate/html` dependency using Composer. | |||
composer require illuminate/html | composer require illuminate/html | ||
Add the service provider to your config/app.php provider list and create a new facade. | Add the service provider to your config/app.php provider list and create a new facade. | ||
'Form' => 'Illuminate\Html\FormFacade', | 'Form' => 'Illuminate\Html\FormFacade', | ||
Revision as of 03:34, 1 June 2015
Installation
Download composer and create an alias so that `composer` launches composer:
wget -O - https://getcomposer.org/installer | php -- --install-dir=$HOME/tmp/ alias composer='php $HOME/tmp/composer.phar'
Set up the laravel project using composer:
composer create-project laravel/laravel projectname --prefer-dist
There are many useful commands that comes with laravel's artisan command line PHP script located in the root of the project directory. You may want to create an alias for artisan:
alias artisan='php artisan'
The initial laravel project will come with scaffolding project files which you may want to remove by running:
artisan fresh
Ensure that the webserver serving the laravel application has permission to write to the directories inside the `storagae` directory. If these directories are not writable by the webserver, no error messages will be displayed or logged.
Troubleshooting
You can see what packages and dependencies were installed by running:
composer show -i
Application
Most of your project files will end up inside the `app` and `resources` directory.
Configuration
Configurations are defined inside the `.env` file located in the root directory of your laravel project. Variables defined in this file override any that are defined in the application configuration files and is the recommended way of setting values.
Routing
All HTTP requests will go through to your `app/Http/` portion of your laravel project.
Models
Models are placed directly in the `app` directory and under the `App` namespace. When working with Models, reference them directly by their namespace or pull in the namespace.
Views
Forms
To use the Illuminate HTML package, pull in the `illuminate/html` dependency using Composer.
composer require illuminate/html
Add the service provider to your config/app.php provider list and create a new facade.
'Form' => 'Illuminate\Html\FormFacade', 'Html' => 'Illuminate\Html\HtmlFacade',
In the blade templates, you can now use:
{!! Form::open() !!}}
{!! Form::label('name', 'Name:') !!}}
{!! Form::text('name', 'default', ['class' => 'blah'] ) !!}}
{!! Form::close() !!}}