Title: Laravel Template | Laravel Admin Panel | Laravel Blade Template
1What is Laravel?
- Laravel is an open source MVC PHP Framework under
MIT License
2MVC Architecture
- Model Model deals with backend logical
structure of the application such as data base
records. In laravel it is denoted as Eloquent
model. - View View deals with frontend such as the HTML,
CSS. In laravel it works with Blade Template
Engine and denoted as View. - Controller Model and View can be communicated
through Controllers. In laravel it is denoted as
Controller.
3MVC Architecture
4Installing Laravel
- Requirements
- The Laravel framework has a few system
requirements. - PHP version should be 5.5.9 or greater
- Apache or any other compatible web server
- Datatabase like MySQL
- Composer dependency manager
- IDE Tool Such as PHP Storm or Any Editor like
Sublim Text, Notepad.
5Installing Laravel
- In Linux Apache, MySQL PHP can be installed
through terminal - apt-get install php5-common libapache2-mod-php5
php5-cli php5-mysql php5-curl
6Installing Laravel
- To Check PHP
- use php -v at terminal to check PHP version
Or else use localhost to check php information
7Installing Laravel
8Installing Laravel
- Laravel utilizes Composer to manage its
dependencies. To install composer through
terminal - curl -sS https//getcomposer.org/installer
php - mv composer.phar /usr/local/bin/composer
- composer global require "laravel/installer1.1"
9Installing Laravel
10Installing Laravel
11Create Laravel App
- To Create Laravel Application through terminal
- composer create-project laravel/laravel
name-of-the-app
12Create Laravel App
- Browse to the following URL in your web browser.
- http//localhost/project-name/public/
13Laravel directory structure
- After crating laravel first app you will notice
there is huge laravel directory structure
14Laravel directory structure
- Let us discuss the directory structure in brief
- It comes as no surprise that all Laravel projects
have essentially the same directory structure -
one in which every file has its designated place.
By gently forcing this directory structure upon
developers, Laravel ensures that your work is
semi-automatically organized the Laravel way. - As you can see, this standard directory structure
consists of quite a few subdirectories. This
wealth of subdirectories can be overwhelming at
first, but well explore them one by one. Most of
your work will happen in the app/ folder, but
heres a basic rundown on the function of each of
the files and folders
15Laravel directory structure
- Top-level Folders and their purpose
- /app/ Contains the controllers, models, views and
assets for your application. This is where the
majority of the code for your application will
live. You will be spending most of your time in
this folder! - /public/ The only folder seen to the world as-is.
This is the directory that you have to point your
web server to. It contains the bootstrap file
index.php which jump-starts the Laravel framework
core. The public directory can also be used to
hold any publicly accessible static assets such
as CSS, Javascript files, images and other files. - /vendor/ A place for all third-party code. In a
typical Laravel application, this includes the
Laravel source code and its dependencies, and
plugins containing additional prepackaged
functionality.
16Laravel directory structure
- /app/Http/routes.php
- Suppose routes.php file contains the below
mentioned code - Routeget('/', function()
-
- return view('welcome')
- )
- When you browse http//localhost/project-name/publ
ic/ - It goes to routes.php and finds get request and
as a result it goes to return view('welcome'). So
it then moves to view directory.
17Laravel directory structure
- /resources/views/welcome.blade.php
- Blade is the simple, yet powerful templating
engine provided with Laravel. - The complete user viewable contents can be placed
here - It uses html, css,javascript and php
18Laravel directory structure
- Suppose routes.php has the below code
- Routeresource('photo', 'PhotoController')
- It goes to App/Http/Controllers/ directory and
finds PhotoController.php which contains logic
for backend data. - This single route declaration creates multiple
routes to handle a variety of RESTful actions on
the photo resource.
19Laravel directory structure
- Methods or Actions Handled By Resource Controller
- Verb Path Action
Route Name - GET /photo index
photo.index - GET /photo/create create
photo.create - POST /photo store
photo.store - GET /photo/photo show
photo.show - GET /photo/photo/edit edit
photo.edit - PUT/PATCH /photo/photo update
photo.update - DELETE /photo/photo destroy
photo.destroy
20Laravel directory structure
- PhotoController.php
- class PhotoController extends Controller
-
- public function index()
-
- return view('welcome')
-
- public function create() //logic for create
photo - public function store() //logic for store photo
- public function show() //logic for show photo
- public function edit() //logic for edit photo
- public function update() //logic for update
photo - public function destroy() //logic for destroy
photo
21Josh- An Example Laravel App
- Want to be more familiar with Laravel ?
- You can go for Josh which is an excellent admin
template for Laravel framework. - This template made with rich features
- Responsive clean design
- User friendly
- Laravel
- HTML5
- CSS3
- Bootstrap 3.3.4
22Josh- Installation
- Josh doesn't ship with whole laravel files, so
you need to intall laravel first. - install laravel using composer by executing
composer create-project laravel/laravel
your_project_name - Next setup Database
- Laravel 5 ships with .env file.
- Incase, you don't find it in root folder of your
laravel installation, - execute following command in terminal to make
it. - cp .env.example .env
- then edit database, environment related details
in that file.
23Josh- Installation
- Directory Permissions
- Laravel 5.1 requires directories within the
storage and the bootstrap/cache directories
should be writable by your web server - Todo this run the below commands on terminal
- chmod -R 775 storage
- chmod 775 bootstrap/cache
24Josh- Installation
- Mail Setup
- Laravel 5.1 stored all mail information in .env
so setup details in .env - Still you need to set sender name and email
details in config/mail.php - If you are testing locally or don't want to send
any mails, then please set 'pretend' gt true, in
config/mail.php at bottom of the page.
25Josh- Installation
- Copying Josh files
- now copy files downloaded from
http//codecanyon.net/item/josh-laravel-admin-temp
late-front-end-crud/8754542to your laravel 5.1
installation. - updating autoload
- composer should know some new files were added
so that it can autoload them - Hit composer dump-autoload in terminal for that
26Josh- Installation
- Delete existing migration files
- Since we are not relying on default migration
tables, please remove following two files from
database/migrations folder - 2014_10_12_000000_create_users_table.php
- 2014_10_12_100000_create_password_resets_table.php
- Otherwise you will get error at later stage of
installation.
27Josh- Installation
- Install Packages
- We use good number of packages to provide great
functionality without re-inventing wheel. - Now add below mentioned packages in
composer.json in require array - "cartalyst/sentinel" "2.0.",
- "laravelcollective/html" "5.1.",
- "cviebrock/eloquent-sluggable" "dev-master",
- "cviebrock/eloquent-taggable" "dev-master",
- "yajra/laravel-datatables-oracle" "5.0"
- update vendors
- now hit composer update in terminal to
download above packages.
28Josh- Installation
- Add service providers
- Open config/app.php and add following lines in
the providers array - Cartalyst\Sentinel\Laravel\SentinelServiceProvider
class, - Collective\Html\HtmlServiceProviderclass,
- Cviebrock\EloquentSluggable\SluggableServiceProvid
erclass, - Cviebrock\EloquentTaggable\ServiceProviderclass,
- yajra\Datatables\DatatablesServiceProviderclass
29Josh- Installation
- In the aliases array add following facades
- 'Activation' gt Cartalyst\Sentinel\Laravel\Facad
es\Activationclass, - 'Reminder' gt Cartalyst\Sentinel\Laravel\Facades
\Reminderclass, - 'Sentinel' gt Cartalyst\Sentinel\Laravel\Facad
es\Sentinelclass, - 'Form' gt Collective\Html\FormFacadecla
ss, - 'Html' gt Collective\Html\HtmlFacadecl
ass, - 'Datatables' gt yajra\Datatables\Datatablesclass
,
30Josh- Installation
- publish vendors
- now we need to publish vendor files so that they
will publish config files, migrations. - Excecute following command in command
prompt/terminal - php artisan sluggabletable blogs
- php artisan taggabletable
- php artisan vendorpublish
- Now we need to add user, groups etc tables to
database, to do so in your command prompt,
execute following code - php artisan migrate
- Note please check all files in
database\migrations to know what fields are being
added.
31Josh- Installation
- setting up config to use our model
- since we have different requirements (extra
fields in users table), we need to change
sentinel config to use our user Model, - to do that open config/cartalyst.sentinel.php
- at line 56, find
- 'model' gt 'Cartalyst\Sentinel\Users\EloquentUser
', - replace it with
- 'model' gt 'App\User',
32Josh- Installation
- Add admin user
- As database tables have been setup, we need to
add admin user to be able to login into adminCP. - Run following command in your command prompt
- php artisan dbseed --classAdminSeeder
- A default admin user with user with username
admin_at_admin.com and password admin will be created
33Josh- Installation
- user's profile pics will be uploaded into
public/uploads/users - So we need to provide write access for that
folder - to do so, please run following command in your
command prompt/terminal - chmod 775 public/uploads/users
- chmod 775 public/uploads/blog
- Finally,
- Browse to http//localhost/josh_laravel51/public/
34Go with Josh
Congratulations! You are ready to rock the world!!
35For More Info Contact Us www.joshadmin.com
For More Info Visit www.joshadmin.com shadmin.c
om