Friday, January 30, 2015

Best Way of deploy in php Laravel application

Deploy in Laravel:

The Best & Easy way for deploying in Laravel is through making a method.

Step 1.

Open up your routes.php page in your /app folder, and append the following line of PHP to the file.

Route::get('/deploy', 'Server@deploy');
Step 2. 
Now go to /app/controllers and make a controller file named Server.php

and add there

class Server extends BaseController {

    public function deploy() {
    
    }
}

Step 3.
Here we can write in this method, all the terminal command which we want to run on server

SSH::into('production')->run(array(
    'cd ~/public_html/mywebsite',
    'git pull origin master'
), function($line){
    echo $line.PHP_EOL; // outputs server feedback
});
Step 4.

Now go to /app/config/remote.php And put your server information here

    'connections' => array(
        'production' => array(
            'host'      => 'hostname',
            'username'  => 'deploy',
            'password'  => '',
            'key'       => '/home/ashish/.ssh/jan20_new',
            'keyphrase' => '',
            'root'      => '/var/www/html',
        ),
    ),

All Done.

Now you can deploy by clicking this http://localhost/deploy

No comments:

Post a Comment