Home >Backend Development >PHP Tutorial >Laravel 4 installation and getting started graphic tutorial, laravel graphic_PHP tutorial
1. Install Composer
First you need to install Composer. Composer is a PHP dependency management tool. The Laravel framework uses Composer to perform installation and dependency management.
Note:
(1) If there is an error when installing Composer, enable php_openssl and php_fileinfo extensions in php.ini because Laravel requires them.
(2) During the installation process, select the correct php.exe location
2. Install Laravel
After Composer is installed, in cmd, execute the following command in your website directory:
<ol class="linenums"><li class="L0">composer create-project laravel/laravel your-project-name</li></ol>
Composer will automatically download and install Laravel for you.
3. Deploy virtual host
For example, my project name is project:
<ol class="linenums">
<li class="L0"><VirtualHost *:80></li>
<li class="L1">DocumentRoot "E:/www/project/public"</li>
<li class="L2">ServerName laravel.dev</li>
<li class="L3">ErrorLog "logs/laravel.log"</li>
<li class="L4">CustomLog "logs/laravel.log" common</li>
<li class="L5"></VirtualHost></li>
</ol>
Of course, you also need to bind the domain name in your hosts:
<ol class="linenums"><li class="L0">127.0.0.1 laravel.dev</li></ol>
At this point, the installation is complete:
4. Implement Hello World
Printing Hello World through routing, add in app/routes.php:
<ol class="linenums">
<li class="L0">Route::get('test', function()</li>
<li class="L1">{</li>
<li class="L2">return 'Hello World!';</li>
<li class="L3">});</li>
</ol>
Because the Laravel template uses Blade, the Controller or view will be introduced in later tutorials!
By default, Eloquent will automatically maintain created_at and updated_at fields in the data table. Simply add these timestamp fields to the table and Eloquent will do the rest for you. If you don't want Eloquent to maintain these fields, add the following property to your model: public $timestamps = false;
Reference: www.golaravel.com/docs/4.1/eloquent/#timestamps
It is recommended that you install debugbar and require the following in composer.json:
"barryvdh/laravel-debugbar": "1.*"