It assumes that a copy of PHP is already installed on your local system. If not, you can read how to install it here
Composer is a package and dependency manager. To install it, open a terminal and change to a new directory. Run this command:
curl -Ss getcomposer.org/installer | php
The results of this command will look like this:
You will see how it downloads and compiles the composer.phar script that we use to install Laravel. While there are many ways to set up a new Laravel application, we will do it using the Laravel Composer script. To install this script, run:
composer global require laravel / installer
Which will look something like this:
This will download and install all the framework files, as well as any dependencies it requires. The packages will be saved in the vendor directory. Once it’s downloaded and installed, you can run the following command:
laravel new uploadApp
You will see something like the following output:
Composer installs all the packages that Laravel needs to run. This may take a few minutes, so please be patient. When finished, run ls -al to see what has been installed.
Here’s a quick breakdown of directories in a typical Laravel application:
- app /: This is the source folder where our application code lives. All controllers, policies and models are in this folder
- bootstrap /: contains the application startup script and some classmap files
- config /: Contains application configuration files. They are usually not directly modified, but instead rely on the values set in the .env (environment) file at the root of the application.
- database /: contains database files including migrations, seeds and test factories
- public /: a public folder containing the compiled resources and of course the index.php file
- routes /: all routes in the app are inside here. There are several different “scopes” of routes, but we will focus on the web.php file.
- storage /: All temporary cache files used by the application, session files, compiled view scripts, and log files.
- tests /: Contains test files for the application, such as unit tests and functional tests.
- vendor /: all dependency packages installed with composer
Now, let’s create the rest of the application and run it with a dedicated artisan command (to save ourselves the hassle of installing and configuring a web server like Apache or nginx). The .env file contains all the configuration values that the files in the / config directory use to configure the application. Internally, you will notice that the configuration value for various parameters is used internally by the application.