Toufiq MahmudTushar
Laravel Project Demonstration
Required Software
 .Net Framework - https://www.microsoft.com/en-us/download/details.aspx?id=52685
 Wamp/Xampp Server
 Composer - https://getcomposer.org/download/
 Php Editor
Installation
 Install .net framework, wamp, composer in a sequence order.
 Open cmd and type - composer
 Go to www/htdocs directory
 Open cmd and type - composer create-project laravel/laravel
myproject --prefer-dist
Note: laravel = package name and myproject = project name. this
command will create a laravel project on htdocs/www
directory.
 Open cmd and type - php artisan serve
Note: Start apache web server. Go to, http://localhost:8000
Project Structure
Project Structure
 app −This directory contains the core code of the application.
 bootstrap −This directory contains the application bootstrapping script.
 config −This directory contains configuration files of application.
 database −This folder contains your database migration and seeds.
 public −This is the application’s document root. It starts the Laravel
application. It also contains the assets of the application like JavaScript, CSS,
Images, etc.
 resources −This directory contains raw assets such as the LESS & Sass files,
localization and language files, andTemplates that are rendered as HTML.
 storage −This directory containsApp storage, like file uploads etc.
Framework storage (cache), and application-generated logs.
 test −This directory contains various test cases.
 vendor −This directory contains composer dependencies.
Routing
 For routing go to routes->web.php and configure request mapping.
 For view file creation, go to resources->views->test.blade.php
 Note: any change in view file not need to restart server but if any changes in
config/controller it may requires to restart the server.
 Sample Routing –
Route::get('user/register','UserController@preRegister');
Route::post('user/register',array('uses'=>'UserController@postRegister'));
DB Configuration
 After installing Laravel, the first thing need to do is to set the write permission
for the directory storage and bootstrap/cache.
chmod 775 /storage
chmod 775 /bootstrap/cache
 Create a database at phpmyadmin for your project.
 Open .env file from root directory and set DB properties.
 Go to config->database.php and set mysql DB properties.
 To create controller, open cmd and type - php artisan make:controller
UserController
Form Helper configuration
 Open cmd and type - composer require laravelcollective/html
 Then type - composer update
 Next, add your new provider to the providers array of config/app.php:
 'providers'=>[CollectiveHtmlHtmlServiceProvider::class,
],
 Finally, add two class aliases to the aliases array of config/app.php:
 'aliases'=>['Form'=>CollectiveHtmlFormFacade::class,
'Html'=>CollectiveHtmlHtmlFacade::class,
],
Eloquent ORM
 To generate database table from command line, go to database->migration
directory and then create class for database table with DML property.
 Table name should be like “users” if Model name “User”
 When classes are ready as database table, open cmd and type- php artisan
migrate
 Model Create command - php artisan make:model User
 Sample User Model Code –
protected $table = 'users';
protected $fillable = ['name','email','password'];
REST API
 To create Rest Controller, open cmd and type - php artisan make:controller --
resource RestUserController
 Add following line to routes->web.php
Sample routing - Route::resource('restUser','RestUserController');
References
 https://laravel.com/docs/5.4
 https://www.tutorialspoint.com/laravel/index.htm
 https://laracasts.com/series/laravel-5-fundamentals
 http://clickcoder.com/laravel-insert-update-delete-with-eloquent-orm/
 https://code.tutsplus.com/tutorials/using-illuminate-database-with-eloquent-
in-your-php-app-without-laravel--cms-27247
Source Code
 https://github.com/toufiqksl/LaravelCRUD
End

Laravel presentation

  • 1.
  • 2.
    Required Software  .NetFramework - https://www.microsoft.com/en-us/download/details.aspx?id=52685  Wamp/Xampp Server  Composer - https://getcomposer.org/download/  Php Editor
  • 3.
    Installation  Install .netframework, wamp, composer in a sequence order.  Open cmd and type - composer  Go to www/htdocs directory  Open cmd and type - composer create-project laravel/laravel myproject --prefer-dist Note: laravel = package name and myproject = project name. this command will create a laravel project on htdocs/www directory.  Open cmd and type - php artisan serve Note: Start apache web server. Go to, http://localhost:8000
  • 4.
  • 5.
    Project Structure  app−This directory contains the core code of the application.  bootstrap −This directory contains the application bootstrapping script.  config −This directory contains configuration files of application.  database −This folder contains your database migration and seeds.  public −This is the application’s document root. It starts the Laravel application. It also contains the assets of the application like JavaScript, CSS, Images, etc.  resources −This directory contains raw assets such as the LESS & Sass files, localization and language files, andTemplates that are rendered as HTML.  storage −This directory containsApp storage, like file uploads etc. Framework storage (cache), and application-generated logs.  test −This directory contains various test cases.  vendor −This directory contains composer dependencies.
  • 6.
    Routing  For routinggo to routes->web.php and configure request mapping.  For view file creation, go to resources->views->test.blade.php  Note: any change in view file not need to restart server but if any changes in config/controller it may requires to restart the server.  Sample Routing – Route::get('user/register','UserController@preRegister'); Route::post('user/register',array('uses'=>'UserController@postRegister'));
  • 7.
    DB Configuration  Afterinstalling Laravel, the first thing need to do is to set the write permission for the directory storage and bootstrap/cache. chmod 775 /storage chmod 775 /bootstrap/cache  Create a database at phpmyadmin for your project.  Open .env file from root directory and set DB properties.  Go to config->database.php and set mysql DB properties.  To create controller, open cmd and type - php artisan make:controller UserController
  • 8.
    Form Helper configuration Open cmd and type - composer require laravelcollective/html  Then type - composer update  Next, add your new provider to the providers array of config/app.php:  'providers'=>[CollectiveHtmlHtmlServiceProvider::class, ],  Finally, add two class aliases to the aliases array of config/app.php:  'aliases'=>['Form'=>CollectiveHtmlFormFacade::class, 'Html'=>CollectiveHtmlHtmlFacade::class, ],
  • 9.
    Eloquent ORM  Togenerate database table from command line, go to database->migration directory and then create class for database table with DML property.  Table name should be like “users” if Model name “User”  When classes are ready as database table, open cmd and type- php artisan migrate  Model Create command - php artisan make:model User  Sample User Model Code – protected $table = 'users'; protected $fillable = ['name','email','password'];
  • 10.
    REST API  Tocreate Rest Controller, open cmd and type - php artisan make:controller -- resource RestUserController  Add following line to routes->web.php Sample routing - Route::resource('restUser','RestUserController');
  • 11.
    References  https://laravel.com/docs/5.4  https://www.tutorialspoint.com/laravel/index.htm https://laracasts.com/series/laravel-5-fundamentals  http://clickcoder.com/laravel-insert-update-delete-with-eloquent-orm/  https://code.tutsplus.com/tutorials/using-illuminate-database-with-eloquent- in-your-php-app-without-laravel--cms-27247
  • 12.
  • 13.