Wednesday, November 30, 2016

Howto Install Laravel Using Composer

Following are instructions to install Laravel Framework 5.3.16 on a Centos Linux 7. The PHP Composer 1.2.2 is used to install all the dependency packages. Detailed instructions on MS Windows environment were initially prepared in previous blog Howto Install Laravel Framework using Composer.

The system on a x86 64-bit computer consist of
CentOS Linux 7.2
HTTPD 2.4.6-40.el7.centos.4
PHP 7.0.13
MySQL 5.7.16-1.el7

Step 1. Install Laravel

Login to a command line terminal (CLI) as a normal user (with sudo rights) and type

 $ sudo yum install composer  
 $ composer -V  

This installs Composer 1.2.2. Minimum requirement is PHP 5.3.2 as mentioned as Composer website.

Install Laravel

 $ sudo yum install composer  
 $ composer -V  

Create your first application called hello.

 $> composer create-project --prefer-dist laravel/laravel hello   

This install Laravel 5.3.16 as shown in the image below. The folder tests and vendor is not shown.

Listing in hello folder.



Step 2. Run Artisan Serve

Start local artisan server

 $ cd hello  
 $ php artisan serve  

Open a web browser and point to the provided URL http://localhost:8000

To allow access to this instance with a domain name such as tboxmy.blogspot.com, start the server with following command

 $ php artisan serve --host= tboxmy.blogspot.com --port=8000  

Step 3. View the Results in HelloWorld

Test Laravel with a helloworld file

Open a terminal and go to the project folder ->hello ->resources ->views
Create a file helloworld.blade.php with following text

1:   <!DOCTYPE html>   
2:   <html>   
3:    <head>   
4:     <title>Laravel</title>   
5:    </head>   
6:    <body>   
7:   Hello World!   
8:    </body>   
9:   </html>   

Display this "VIEW" when the URL is /hello by editing the file web.php in the project folder ->hello ->routes

1:   Route::get('/hello', function () {    
2:     return view('helloworld');   
3:   });   

Save the file and start the artisan serve.

Open a web browser and type the URL mentioned above in Step 2. E.g.
http://localhost:8000/hello

This displays the Hello World! page with HTML formatting from the file resources/views/helloworld.blade.php

Done

No comments:

Blog Archive