A detailed overview of the laravel framework, created by Awulonu Obinna and presented at: Laravel Abuja.
Author details:
Twitter – https://www.twitter.com/awulonu_obinna
Facebook – https://www.facebook.com/awulonuobinna
GitHub – https://www.github.com/obinosteve
2. ABOUT THE SPEAKER
Developer and Web Admin @ Headquarters Nigerian Airforce
Twitter – https://www.twitter.com/awulonu_obinna
Facebook – https://www.facebook.com/awulonuobinna
GitHub – https://www.github.com/obinosteve
#phpenthusiast #laravelevangelist
3. What is Laravel?
Laravel is a free, open-sourcePHP web framework, used for
development of web applications following the model-view
controller (MVC) architectural pattern.
4. What is a Framework?
A framework is a piece of code which dictates the architecture your
project will follow. Once you choose a framework to work with, you
have to follow the framework's code and design methodologies. The
framework will provide you with hooks and callbacks, so that
you build on it - it will then call your plugged-in code whenever it
wishes, a phenomenon called Inversion of Control.
5. What is mvc?
The Model-View-Controller (MVC) is an architectural pattern
that provides a reusable solution to resolve common problems
that occurs while developing a Web application. It separates an
application into three main logical components: the model, view
and controller.
6. Model:
The model is responsible for managing the data of the application. It
responds to the request from the view and it also responds to
instructions from the controller to update itself.
View:
The View component is used for all the UI logic of the application.
The view includes all the UI components such as text boxes,
dropdowns, buttons, etc. that the final user interacts with.
Controller:
Controller is responsible for controlling the application logic and acts as the
coordinator between the View and the Model. The Controller receives input from
users via the View, then process the user's data with the help of Model and passing
the results back to the View.
7. Benefits of the MVC Pattern
Separation of concerns: Enables you to ensure that various application concerns
into different and independent software components. Thus, it allows you to work on a
single component independently.
Simplified testing and maintenance: Enables you to test each component
independently.
Extensibility: Enables the model to include a set of independent components that you
can easily modify or replace based on the application requirement.
Faster development process
Ability to provide multiple views
SEO friendly Development platform: It is very easy to develop SEO-friendly URLs to
generate more visits from a specific application.
9. Did we miss anything? Routing?
What is Routing in Laravel ?
10. Routing
Routing defines how the application will process and respond to
incoming HTTP request. You can use URLs that properly describes the
controller action to which the request needs to be routed.
Routing enables use of URLs that are descriptive of the user actions
and are more easily understood by the users.
e.g Instead of http://myapplication/Users.php?id=1
we can
http://myapplication/Users/1
12. Environment Setup
Laravel Homestead https://laravel.com/docs/5.5/homestead
Laragon https://laragon.org/
Method 3:
Wamp server: http://www.wampserver.com/en/
Composer: https://getcomposer.org/download/
Nodejs: https://nodejs.org/en/
Npm: Installed on your computer when you install Node.js
13. Create new Laravel Project
From your command prompt or terminal or git bash, run:
composer create-project --prefer-dist laravel/laravel projectname
Run your first laravel application:
php artisan serve
CONGRATULATIONS
You have successfully ran your first laravel app
15. App Directory: Contains the core code of your application. A variety of
other directories will be generated inside the app directory as you use
the make Artisan commands to generate classes.
Bootstrap Directory: Contains the app.php file which bootstraps the
framework.
Config Directory: Contains all of your application's configuration files.
Database Directory: Contains your database migration and seeds.
Public Directory: Contains the index.php file, which is the entry point for
all requests entering your application and configures autoloading. This
directory also houses your assets such as images, JavaScript, and CSS.
Resources Directory: Contains your views as well as your raw, un-compiled
assets such as LESS, SASS, or JavaScript.
Routes Directory: Contains all of the route definitions for your application.
Storage Directory: Contains your compiled Blade templates, file based
sessions, file caches, and other files generated by the framework.
Tests Directory: Contains your automated tests.
Vendor Directory: Contains your composer dependencies.
16. Default Laravel Technologies
The following technologies are included by default:
Jquery: A cross-platform Js library designed to simplify the client-side scripting of
HTML.
Bootstrap: Bootstrap is the most popular HTML, CSS, and Js framework for
developing responsive, mobile-first web sites
Axios: A Js library used to make http requests from node.js or XMLHttpRequests
from the browser and it supports the Promise API that is native to JS ES6.
Vue: Popular Js framework for building user interfaces.
Lodash: A Js library that helps programmers write more concise and easier to
maintain Js.
Cross-env: Run scripts that set and use environment variables across platforms
18. Laravel App Development Steps
Verify that inside the .env file, APP_KEY is set and APP_DEBUG is set
to true
Set the DB_CONNECTION, DB_HOST, DB_PORT, DB_DATABASE,
DB_USERNAME and DB_PASSWORD correctly.
Create and migrate your database migration
Create the model
Create the controller
Create the route inside your route/web.php file
Create the View
19. Say Hi to Eloquent ORM!
Eloquent ORM allow developers use Active Record pattern.
Active Record pattern is a technique of wrapping database into objects.
By using this technique, developers can present data stored in a
database table as class, and row as an object. Each database
table has a corresponding “Model” which is used to interact with that
table. It helps to make our codes look cleaner and readable. We can
use Eloquent ORM to create, edit, manipulate, query and delete entries
easily
21. Understanding Controllers
Index: Display a listing of the resource.
Create: Show the form for creating a new resource.
Store: Store a newly created resource in the storage.
Show: Display the specified resource.
Edit: Show the form for editing the specified resource.
Update: Update the specified resource in storage.
Destroy: Delete the specified resource from storage.