Laravel is an open source MVC web development PHP framework, according to Wikipedia it was the most widely used PHP web development framework in 2013 and in 2014 it became the most watched PHP project on GitHub. It has a great community and it is rapidly evolving.
On the Laravel website there is a tutorial on how to setup a development environment using vagrant and virtualbox. Laravel offers a pre-built vagrant box, called Homestead, which has all the necessary tools for developing Laravel applications.
In this article I will explain how to create a development environment for Laravel using XAMPP under Linux Mint.
XAMPP is completely free and is available for every platform (Linux, Mac, Windows). XAMPP stands for cross platform(X) Apache, MySQL, PHP and Perl environment. Download the latest package from the XAMPP download page. When downloaded, check if the file has execute permissions:
In case the installer does not have execute permission you can assign using:
# using the +x flag to assign the execute permission chmod +x xampp-linux-x64-5.6.3-0-installer.run # using octal-mode: # 7 - user has all the permissions (read, write, execute) # 5 - group has read and execute permissions # 5 - others have read and execute permissions chmod 755 xampp-linux-x64-5.6.3-0-installer.run
Run the installation of XAMPP with the: sudo ./xampp-linux-x64-5.6.3-0-installer.run - command, this will open a graphical installer. The installation is straightforward and it will install everything under /opt/lampp/ directory. Once the installation is finished, you can start the graphical configuration manager for XAMPP. You can do this by navigating to /opt/lampp/ and starting the sudo manager-linux-x64.run command. The following window will open up:
On the second tab, you can stop/start/restart the services and update the configurations of the applications (Apache, MySQL).
For example I use the 8989 port for Apache, so I need to update the Port on the configuration window, then hit OK and restart the Apache Web Server. Keep in mind the selected port has to be free and should not be used by other applications.
Laravel uses Composer and php5-cli to generate the default project setup. Composer is dependency manager for PHP, while php5-cli are command line tools for PHP 5.
# install composer to the current directory curl -sS https://getcomposer.org/installer | php # installing php5-cli using apt apt-get install php5-cli
Creating a default Laravel project
When everything is installed, navigate to /opt/lampp/htdocs (this is the directory which Apache uses to display the webpages).
# creating the sample_laravel_app using composer # into the /opt/lampp/htdocs/laravel folder greg@earth /opt/lampp/htdocs/laravel $ php5 /opt/lampp/composer/composer.phar create-project laravel/laravel sample_laravel_app --prefer-dist # have to change the ownership and permissions of the folder storage greg@earth /opt/lampp/htdocs/laravel $ chmod -R 777 sample_laravel_app/app/storage greg@earth /opt/lampp/htdocs/laravel $ chown -R greg:www-data sample_laravel_app/app/storage
That’s it, a new project with the Laravel framework was created. If you navigate to the correct route and see this in the browser, the project was successfully installed.
You are now ready to start the development on the project.