This is very basic laravel presentation. I tried to cover all the topics in this presentation. For more information, please feel free to email me - toufiqist@gmail.com
3. 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
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 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'));
7. 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
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
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'];
10. 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');