How to build a Project Management App in Laravel 5 – Part 1
In this tutorial, we are going to learn how to build a simple and very useful Project Management app in Laravel 5.
I like to develop following best practices and using the latest and best tools for development.
1. Fresh Installation of Laravel
The nature of my job makes me switch between several languages often, So I have different directories for different stacks. I have a workspace just for Laravel projects. I named the directory lara-workspace. I encourage you to have something similar.
We’ll give the name of our app Prego. Honestly, I still don’t know how I derived that name, So please don’t feel offended if it means something nasty in any language.
Let’s do a fresh installation of Laravel like so:
1 |
composer create-project laravel/laravel --prefer-dist Prego |
Or if you have Laravel installer like me, you can do something like:
1 |
laravel new Prego |
Cd into the directory Prego like so:
1 |
cd Prego |
I like to use version control for all my projects. So let’s initialize git like so:
1 |
git init |
I have created a project on Github, So I’ll just add the URL like so:
1 |
git remote add origin https://github.com/goodheads/prego.git |
I use Sublime for virtually all my projects because it’s fast and has a plethora of cool packages for development. So I’ll open the Prego directory in Sublime.
Delete the .env.example file that ships with Laravel.
Now add everything to git
1 |
git add . |
1 |
git commit -m "Initial Commit" |
1 |
git push origin master |
Note: We’re going to be doing this a lot. So I recommend you have aliases for them. The aliases I use are ga, gc and gpom
2. Let’s Set Up Homestead
Make sure you have Vagrant and VirtualBox or Vmware Installed.
Laravel Homestead is an official prepackaged Vagrant box that provides you a wonderful development environment without requiring you to install PHP, HHVM, a web server, and any other server software on your local machine. No more worrying about messing up your operating system! Vagrant boxes are completely disposable. If something goes wrong, you can destroy and re-create the box in minutes!
The Laravel Documentation and Eric Barnes Post shows you how to set it up.
Let’s Open our Homestead.yaml file. Add the mapping to the sites section like so:
Then add the mapping to the database section like so:
Now, it’s time to edit our hosts file and add a URL for development
Go to /etc and open the hosts file, Add:
Now that we have that configured, let’s go ahead and run:
1 |
vagrant up |
If you go to your browser and enter prego.dev:8000 , you’ll be greeted with the default laravel 5 page.
3. Change Default Namespace
Go through several files in the app/Http/Controller folder and the other folders in the app directory. An example is the Controller.php file in app/Http/Controller folder like so:
1 2 3 4 5 6 7 8 9 10 11 12 13 |
<?php namespace App\Http\Controllers; use Illuminate\Foundation\Bus\DispatchesJobs; use Illuminate\Routing\Controller as BaseController; use Illuminate\Foundation\Validation\ValidatesRequests; use Illuminate\Foundation\Auth\Access\AuthorizesRequests; abstract class Controller extends BaseController { use AuthorizesRequests, DispatchesJobs, ValidatesRequests; } |
You’ll discover the namespace starts with App. Let’s change that to our own custom namespace
Run the command from the terminal like so:
1 |
php artisan app:name Prego |
Now if you check the Controller file and several other files, you’ll discover that the namespace now starts with Prego
1 2 3 4 5 6 7 8 9 10 11 12 13 |
<?php namespace Prego\Http\Controllers; use Illuminate\Foundation\Bus\DispatchesJobs; use Illuminate\Routing\Controller as BaseController; use Illuminate\Foundation\Validation\ValidatesRequests; use Illuminate\Foundation\Auth\Access\AuthorizesRequests; abstract class Controller extends BaseController { use AuthorizesRequests, DispatchesJobs, ValidatesRequests; } |
4. Tidy Up Laravel Files
For the sake of this tutorial, I am going to delete some default files that comes with Laravel and implement some functionalities on our own. I don’t want everything that’s happening looking like Magic!
a) Delete the Auth Folder
b) Delete the two migration files that come shipped with Laravel i.e the create_users_table and create_password_resets_table  from the database/migrations folder
c) Delete the sass folder in resources/assets directory
d) Delete the gulpfile.js file in the root directory. We won’t be using Laravel Elixir
e) Delete the welcome.blade.php file in resources/views directory. That’s actually what serves the default Laravel 5 page.
Refresh your browser, you’ll discover there is an error on the page  and that’s because we deleted the view that presents that.
Don’t Panic, Just Stay Calm and join me in the next post.
If you have any questions or observations, please drop your thoughts in the comment section below
- How to build your own Youtube – Part 10 - August 1, 2016
- How to build your own Youtube – Part 9 - July 25, 2016
- How to build your own Youtube – Part 8 - July 23, 2016
- How to build your own Youtube – Part 6 - July 6, 2016
- Introducing Laravel Password v1.0 - July 3, 2016
- How to build your own Youtube – Part 5 - June 28, 2016
- How to build your own Youtube – Part 4 - June 23, 2016
- How to build your own Youtube – Part 3 - June 15, 2016
- How to build your own Youtube – Part 2 - June 8, 2016
- How to build your own Youtube – Part 1 - June 1, 2016