Laravel is often referred to as the “PHP Framework For Web Artisans”. It is an interesting technology to work with as a server-side(back-end) developer but as a front-end developer you can work with it too.
To be able to work on a laravel project, there are some basic requirements:
* Composer: This is a tool for dependency management in PHP, if you do not have it installed in your computer globally please pause and install it here.
* PHP: It is advisable to root for PHP versions >= 7.0, get it here too
- Command Line Interface : No actual recommendation here, anyone you choose is suitable(git bash, CMD, Terminal etc).
Laravel uses a different view rendering technique called blading. Well I will not go into details on that now, because it may bore you out. So let’s get right to it.
Stage 1 : Setting up project on local machine
- Step 1: Clone the laravel project to your local machine preferably in your www(windows) and www/html(linux) folder. you can clone a laravel proejct here for test.
- Step 2: Enter into the project directory my running the cd command cd project-name
- Step 3: Run the composer command to download and install all required laravel dependencies. composer install
- Step 4: Make a copy of the sample environment file (at this point the project should be open in your text editor) cp .env.example .env (you should see the new file added through your editor).
- Step 5: Generate your unique APP_KEY php artisan key:generate The key will automatically be updated in your environment file in your editor. If it doesn’t you can always copy and paste.
Stage 2 : Connecting your database
- Step 1: Go to your https://localhost/phpmyadmin, login and create a new database
- Step 2: Go to your .env file and edit DB_DATABASE , DB_USERNAME and DB_PASSWORD to match the credentials you just created, where DB_USERNAME and DB_PASSWORD are the credentials of your phpmyadmin.
- Step 3: Go to your CLI and run php artisan migrate to create the appropriate tables for you in your local database.
- Step 4: Run php artisan db:seed seed the tables for you in your local database.
- Step 5: Or you can run step 3& 4 together as php artisan migrate --seed to create the appropriate tables and seed them in your local database.
Stage 3 : Food is ready
The project is ready to be served in your local machine. To do this run php artisan serve to serve the project at localhost:8080 or 127.0.0.1:8000 .
To alternatively serve in through another port run php artisan serve --port=port no . For instance if port 8000 is occupied you can run it on 8080 like this php artisan serve --port=8080 .
Visit 127.0.0.1:8080 or 127.0.0.1:port no to see your project up and running
There are so many things I would love to add to this, but let’s keep it short and concise. In the next article, I will talk about Working with Laravel as a Front-end Developer .
I hope this was simple and straight forward, If you have any corrections or additions please feel free to drop a comment.