Presentation is loading. Please wait.

Presentation is loading. Please wait.

What is Laravel? Laravel is an open source MVC PHP Framework under MIT License.

Similar presentations


Presentation on theme: "What is Laravel? Laravel is an open source MVC PHP Framework under MIT License."— Presentation transcript:

1 What is Laravel? Laravel is an open source MVC PHP Framework under MIT License

2 MVC 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.

3 MVC Architecture

4 Installing 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++.

5 Installing 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

6 Installing Laravel To Check PHP use php -v at terminal to check PHP version Or else use localhost to check php information

7 Installing Laravel

8 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/installer=~1.1"

9 Installing Laravel

10 To check Composer

11 Create Laravel App To Create Laravel Application through terminal $ composer create-project laravel/laravel name-of-the- app

12 Create Laravel App Browse to the following URL in your web browser. http://localhost/project-name/public/

13 Laravel directory structure After crating laravel first app you will notice there is huge laravel directory structure

14 Laravel 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 we’ll explore them one by one. Most of your work will happen in the app/ folder, but here’s a basic rundown on the function of each of the files and folders:

15 Laravel 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.

16 Laravel directory structure /app/Http/routes.php Suppose routes.php file contains the below mentioned code Route::get('/', function() { return view('welcome'); }); When you browse http://localhost/project-name/public/http://localhost/project-name/public/ 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.

17 Laravel 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

18 Laravel directory structure Suppose routes.php has the below code Route::resource('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.

19 Laravel directory structure Methods or Actions Handled By Resource Controller VerbPath 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}/editedit photo.edit PUT/PATCH/photo/{photo}update photo.update DELETE/photo/{photo} destroy photo.destroy

20 Laravel 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 } }

21 Josh- 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

22 Josh- 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.

23 Josh- 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

24 Josh- 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' => true, in config/mail.php at bottom of the page.

25 Josh- Installation  Copying Josh files  now copy files downloaded from http://codecanyon.net/item/josh-laravel-admin- template-front-end-crud/8754542to your laravel 5.1 installation. http://codecanyon.net/item/josh-laravel-admin- template-front-end-crud/8754542  updating autoload  composer should know some new files were added so that it can autoload them  Hit $ composer dump-autoload in terminal for that

26 Josh- 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.p hp Otherwise you will get error at later stage of installation.

27 Josh- 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.

28 Josh- Installation Add service providers Open config/app.php and add following lines in the providers array Cartalyst\Sentinel\Laravel\SentinelServiceProvider::c lass, Collective\Html\HtmlServiceProvider::class, Cviebrock\EloquentSluggable\SluggableServiceProvi der::class, Cviebrock\EloquentTaggable\ServiceProvider::class, yajra\Datatables\DatatablesServiceProvider::class

29 Josh- Installation In the $aliases array add following facades 'Activation' => Cartalyst\Sentinel\Laravel\Facades\Activation::class, 'Reminder' => Cartalyst\Sentinel\Laravel\Facades\Reminder::class, 'Sentinel' => Cartalyst\Sentinel\Laravel\Facades\Sentinel::class, 'Form' => Collective\Html\FormFacade::class, 'Html' => Collective\Html\HtmlFacade::class, 'Datatables' => yajra\Datatables\Datatables::class,

30 Josh- 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 sluggable:table blogs $ php artisan taggable:table $ php artisan vendor:publish  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.

31 Josh- 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' => 'Cartalyst\Sentinel\Users\EloquentUser', replace it with 'model' => 'App\User',

32 Josh- 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 db:seed --class=AdminSeeder  A default admin user with user with username admin@admin.com and password admin will be created

33 Josh- 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/http://localhost/josh_laravel51/public/

34 Go with Josh Congratulations! You are ready to rock the world!!

35 For More Info Contact Us: www.joshadmin.com For More Info Visit : www.joshadmin.com shadmin.com


Download ppt "What is Laravel? Laravel is an open source MVC PHP Framework under MIT License."

Similar presentations


Ads by Google