Laravel TutorialChange default routing behaviour in Laravel 5.2.31 +CustomException class in LaravelDeploy Laravel 5 App on Shared Hosting on Linux ServerLaravel ArtisanLaravel AuthenticationLaravel AuthorizationLaravel Blade TemplatesLaravel CashierLaravel CollectionsLaravel Common Issues & Quick FixesLaravel ConstantsLaravel ControllersLaravel Cron basicsLaravel Cross Domain RequestLaravel Custom Helper functionLaravel DatabaseLaravel Database MigrationsLaravel Database SeedingLaravel Directory StructureLaravel DockerLaravel EloquentLaravel Eloquent : RelationshipLaravel Eloquent: Accessors & MutatorsLaravel Eloquent: ModelLaravel Error HandlingLaravel Events and ListenersLaravel Filesystem / Cloud StorageLaravel Form Request(s)Laravel Getting started with laravel-5.3Laravel HelpersLaravel HTML and Form BuilderLaravel InstallationLaravel Installation GuideLaravel Introduction to laravel-5.2Laravel Introduction to laravel-5.3Laravel lumen frameworkLaravel Macros in Eloquent RelationshipLaravel MailLaravel MiddlewareLaravel ObserverLaravel PackagesLaravel PaginationLaravel Permissions for storageLaravel PoliciesLaravel QueuesLaravel RequestsLaravel Route Model BindingLaravel RoutingLaravel SeedingLaravel ServicesLaravel SocialiteLaravel Task SchedulingLaravel TestingLaravel Token Mismatch Error in AJAXLaravel use fields aliases in EloquentLaravel Useful linksLaravel ValetLaravel ValidationMultiple DB Connections in LaravelNaming Files when uploading with Laravel on WindowsRemove public from URL in laravelSparkpost integration with Laravel 5.4

Laravel Getting started with laravel-5.3

From WikiOD

Remarks[edit | edit source]

This section provides an overview of what laravel-5.3 is, and why a developer might want to use it.

It should also mention any large subjects within laravel-5.3, and link out to the related topics. Since the Documentation for laravel-5.3 is new, you may need to create initial versions of those related topics.

Hello World Example (Basic) and with using a view[edit | edit source]

The basic example

Open routes/web.php file and paste the following code in file:

Route::get('helloworld', function () {
    return '<h1>Hello World</h1>';

here 'helloworld' will act as page name you want to access,

and if you don't want to create blade file and still want to access the page directly then you can use laravel routing this way

now type localhost/helloworld in browser address bar and you can access page displaying Hello World.

The next step.

So you've learned how to create a very simple Hello World! page by returning a hello world sentence. But we can make it a bit nicer!

Step 1.

We'll start again at our routes/web.php file now instead of using the code above we'll use the following code:

Route::get('helloworld', function() {
    return view('helloworld');

The return value this time is not just a simple helloworld text but a view. A view in Laravel is simply a new file. This file "helloworld" contains the HTML and maybe later on even some PHP of the Helloworld text.

Step 2.

Now that we've adjusted our route to call on a view we are going to make the view. Laravel works with blade.php files in views. So, in this case, our route is called helloworld. So our view will be called helloworld.blade.php

We will be creating the new file in the resources/views directory and we will call it helloworld.blade.php

Now we'll open this new file and edit it by creating our Hello World sentence. We can add multiple different ways to get our sentence as in the example below.

        <h1> Hello World! </h1>

            echo "Hello PHP World!";


now go to your browser and type your route again like in the basic example: localhost/helloworld you'll see your new created view with all of the contents!

Local Development Server[edit | edit source]

If you have PHP installed locally and you would like to use PHP's built-in development server to serve your application, you may use the serve Artisan command. This command will start a development server at http://localhost:8000:

php artisan serve

Of course, more robust local development options are available via Homestead and Valet.

Also it's possible to use a custom port, something like 8080. You can do this with the --port option.

php artisan serve --port=8080

If you have a local domain in your hosts file, you can set the hostname. This can be done by the --host option.

php artisan serve

You can also run on a custom host and port, this can be done by the following command.

php artisan serve --port=8080

Server Requirements[edit | edit source]

The Laravel framework has a few system requirements. Of course, all of these requirements are satisfied by the Laravel Homestead virtual machine, so it's highly recommended that you use Homestead as your local Laravel development environment.

However, if you are not using Homestead, you will need to make sure your server meets the following requirements:

  • PHP >= 5.6.4
  • OpenSSL PHP Extension
  • PDO PHP Extension
  • Mbstring PHP Extension
  • Tokenizer PHP Extension
  • XML PHP Extension

Installing Laravel[edit | edit source]


You need PHP >= 5.6.4 and Composer installed on your machine. You can check version of both by using command:

For PHP:

php -v

Output like this:

PHP 7.0.9 (cli) (built: Aug 26 2016 06:17:04) ( NTS )
Copyright (c) 1997-2016 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2016 Zend Technologies

For Composer

You can run command on your terminal/CMD:

composer --version

Output like this:

composer version 1.2.1 2016-09-12 11:27:19

Laravel utilizes Composer to manage its dependencies. So, before using Laravel, make sure you have Composer installed on your machine.

Via Laravel Installer[edit | edit source]

First, download the Laravel installer using Composer:

composer global require "laravel/installer"

Make sure to place the $HOME/.composer/vendor/bin directory (or the equivalent directory for your OS) in your $PATH so the laravel executable can be located by your system.

Once installed, the laravel new command will create a fresh Laravel installation in the directory you specify. For instance, laravel new blog will create a directory named blog containing a fresh Laravel installation with all of Laravel's dependencies already installed:

laravel new blog

Via Composer Create-Project[edit | edit source]

Alternatively, you may also install Laravel by issuing the Composer create-project command in your terminal:

composer create-project --prefer-dist laravel/laravel blog

Setup[edit | edit source]

After you are complete with the Laravel installation, you will need to set permissions for the storage and Bootstrap folders.

Note: Setting permissions is one of the most important processes to complete while installing Laravel.

Local Development Server

If you have PHP installed locally and you would like to use PHP's built-in development server to serve your application, you may use the serve Artisan command. This command will start a development server at http://localhost:8000:

php artisan serve

Open your browser request url http://localhost:8000

Hello World Example (Basic)[edit | edit source]

Open routes file. Paste the following code in:

Route::get('helloworld', function () {
    return '<h1>Hello World</h1>';

after going to route http://localhost/helloworld it displays Hello World.

The routes file is located /routes/web.php

Web Server Configuration for Pretty URLs[edit | edit source]

If you installed Laravel via Composer or the Laravel installer, below configuration you will need.

Configuration for Apache Laravel includes a public/.htaccess file that is used to provide URLs without the index.php front controller in the path. Before serving Laravel with Apache, be sure to enable the mod_rewrite module so the .htaccess file will be honored by the server.

If the .htaccess file that ships with Laravel does not work with your Apache installation, try this alternative:

Options +FollowSymLinks
RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]

Configuration for Nginx If you are using Nginx, the following directive in your site configuration will direct all requests to the index.php front controller:

location / {
    try_files $uri $uri/ /index.php?$query_string;

Of course, when using Homestead or Valet, pretty URLs will be automatically configured.