Why we need to INSTALL LARAVEL AS A GIT SUBMODULE:
![]() |
| Installation of Laravel 5.4 |
Sometimes we want to have LARAVEL installation separate from rest of public files. We can solve this case by installing laravel as a git submodule. We can update our laravel files through git without touching code of our application.
Installing Laravel as git submodule
To install laravel as git submodule we need to have a running development server and git installed. Installing of laravel as a git submodule will be done in command line.
Complete these steps to install Laravel as a git submodule:
- Create myapp directory to hold your files in web server’s directory.
- Navigate the root of myapp directory in your command line.
- Use the below code to Install git and download your project files.
$ git init
$ git clone git@github.com:laravel/laravel.git
- We need public directory to move /laravel and delete anything else by using the below code.
$ cd laravel
$ rm –r app bootstrap vendor
- Move back to the root directory, create a framework directory and then use the code mentioned below to add Laravel as sub-module.
$ cd ..
$ mkdir framework
$ cd framework
$ git init
$ git submodule add https://github.com/laravel/laravel.git
- Now run the composer and use following code to install the framework.
php composer.phar install
- Open directory laravel/public/index.php and search the following lines:
require __DIR__.'/../bootstrap/autoload.php';
$app = require_once __DIR__.'/../bootstrap/start.php';
- Now, change the previous lines of code to the following lines:
require __DIR__.'/../../framework/laravel/bootstrap/autoload.php';
$app = require_once __DIR__.'/../../framework/laravel/bootstrap/start.php';
How to setup a virtual host and development environment in Apache:
A web server is needed to develop a Laravel App. We can use the built-in web server in Php 5.4 or up versions of Php. Web stack is needed for more functionality. In this method, we need any operating system with Apache server.
Follow these steps to setup a virtual host and development environment in Apache.
- Open the WAMP Apache httpd.conffile which is located in C:/wamp/bin/apache/Apach2.#.#/conf.
- Put the line #Include conf/extra/httpd-vhosts.confand remove first #.
- Move to the extradirectory, open the httpd-vhosts.conffile, and add the
Code mentioned below:
<VirtualHost *:80>
ServerAdmin {your@email.com}
DocumentRoot "C:/path/to/myapp/public"
ServerName myapp.dev
<Directory "C:/path/to/myapp/public">
Options Indexes FollowSymLinks
AllowOverride all
# onlineoffline tag - don't remove
Order Deny,Allow
Deny from all
Allow from 127.0.0.1
</Directory>
</VirtualHost>
- Restart the Apache service.
- Open the directory C:/Windows/System32/drivers/etc.
- Open the file hosts in the text editor.
- Add 127.0.0.1 myapp.dev at the bottom of the file.
HOW TO CREATE CLEAN URL’S IN LARAVEL:
We use default URL http://{your-server}/public while installing Laravel but we can remove /public in URL by using Apache’s mod-rewrite.
To create Clean URL’s do these steps:
Before that make sure you have a fresh installation of Laravel and everything is running on a properly configured server.
- · Add a .htaccessfile in your root App and use this code:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^(.*)$ public/$1 [L]
</IfModule>
- · Go to http://{your-server}and view your application.
HOW TO CONFIGURE LARAVEL:
After installing Laravel it is not necessary to configure. If we want to make sure to updates there are few settings.
To configure Laravel Follow these steps:
- · Open /app/config/app.phpand update these lines:
'url' => 'http://localhost/,
'locale' => 'en',
'key' => 'Seriously-ChooseANewKey',
- · Open app/config/database.phpand choose your prefered database:
'default' => 'mysql',
'connections' => array(
'mysql' => array(
'driver' => 'mysql',
'host' => 'localhost',
'database' => 'database',
'username' => 'root',
'password' => '',
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
),
),
· Now go to the root of the app and make sure the storage folder is writable in command line:
chmod –R 777 app/storage

Comments
Post a Comment