Laravel


This draft deletes the entire topic.

expand all collapse all

Examples

  • 7

    Laravel applications are installed and managed with Composer, a popular PHP dependency manager. There are two ways to create a new Laravel application.

    Via Composer

    $ composer create-project laravel/laravel [foldername]
    

    Replace [foldername] with the name of the directory you want your new Laravel application installed to. It must not exist before installation. You may also need to add the Composer executable to your system path.

    Via the Laravel installer

    Laravel provides a helpful command line utility to quickly create Laravel applications. First, install the installer:

    $ composer global require laravel/installer
    

    You have to make sure that the Composer binaries folder is within your $PATH variable to execute the Laravel installer.

    First, look if it already is in your $PATH variable

    echo $PATH

    If everything is correct, the output should contain something like this:

    Users/yourusername/.composer/vendor/bin

    If not, edit your .bashrc or, if your using ZSH, your .zshrc so it contains the path to your Composer vendor directory.

    Once installed, this command will create a fresh Laravel installation in the directory you specify.

    laravel new [foldername]
    

    You can also use . (a dot) in place of [foldername] to create the project in the current working directory without making a sub-directory.

    Running the application

    Laravel comes bundled with a PHP-based web server which can be started by running

    $ php artisan serve
    

    By default the HTTP server will use port 8000, but if the port is already in use or if you want to run multiple Laravel applications at once, you can use the --port flag to specify a different port:

    $ php artisan serve --port=8080
    

    Using a different server

    If you prefer to use a different web server software, some configuration files are provided for you inside the public directory of your project; .htaccess for Apache and web.config for ASP.NET. For other software such as Nginx, you can convert the Apache configurations using various online tools.


    The framework needs the web server user to have write permissions on the following directories:

    • /storage
    • /bootstrap/cache

    On *nix operating systems this can be achieved by

    chgrp -R www-data:www-data storage bootstrap/cache
    chmod -R ug+rwx storage bootstrap/cache
    

    (where "www-data" is the name (and group) of the web server user)


    The web server of your choice should be configured to serve content from your project's /public directory, which is usually done by setting it as the document root. The rest of your project should not be accessible through your web server.

    If you set everything up properly, navigating to your website's URL should display the default landing page of Laravel.

  • 3

    The Laravel framework has the following requirements:

    5.3
    • PHP >= 5.6.4
    • XML PHP Extension
    • PDO PHP Extension
    5.1 (LTS)5.2
    • PHP >= 5.5.9
    • PDO PHP Extension
    • Laravel 5.1 is the first version of Laravel to support PHP 7.0.
    5.0
    • PHP >= 5.4, PHP < 7
    • OpenSSL PHP Extension
    • Tokenizer PHP Extension
    • Mbstring PHP Extension
    • JSON PHP extension (only on PHP 5.5)
    4.2
    • PHP >= 5.4
    • Mbstring PHP Extension
    • JSON PHP extension (only on PHP 5.5)
  • 1

    LaraDock is a Laravel Homestead like development environment but for Docker instead of Vagrant. https://github.com/LaraDock/laradock

    Installation

    *Requires Git and Docker

    Clone the LaraDock repository:

    A. If you already have a Laravel project, clone this repository on your Laravel root directory:

    git submodule add https://github.com/LaraDock/laradock.git
    

    B. If you don't have a Laravel project, and you want to install Laravel from Docker, clone this repo anywhere on your machine:

    git clone https://github.com/LaraDock/laradock.git
    

    Basic Usage

    1. Run Containers: (Make sure you are in the laradock folder before running the docker-compose commands).

      Example: Running NGINX and MySQL: docker-compose up -d nginx mysql

      There are a list of available containers you can select to create your own combinations.

      nginx, hhvm, php-fpm, mysql, redis, postgres, mariadb, neo4j, mongo, apache2, caddy, memcached, beanstalkd, beanstalkd-console, workspace

    2. Enter the Workspace container, to execute commands like (Artisan, Composer, PHPUnit, Gulp, ...).

      docker-compose exec workspace bash

    3. If you don't have a Laravel project installed yet, follow the step to install Laravel from a Docker container.

      a. Enter the Workspace container.

      b. Install Laravel. composer create-project laravel/laravel my-cool-app "5.3.*"

    4. Edit the Laravel configurations. Open your Laravel's .env file and set the DB_HOST to your mysql:

      DB_HOST=mysql

    5. Open your browser and visit your localhost address.

Please consider making a request to improve this example.

Remarks

Created by Taylor Otwell as a free open-source PHP web framework, Laravel is meant to ease and accelerate the development process of web applications with a great taste for simplicity.

It follows the model–view–controller (MVC) architectural pattern as well as the PSR-2 coding standard, and the PSR-4 autoloading standard.

Running a Test Driven Development (TDD) in Laravel is fun and easy to implement.

Hosted on GitHub and available at https://github.com/laravel/laravel, Laravel boasts of a micro-services architecture, making it tremendously extendable and this, with ease, with the use of custom-made and or existing third-party packages.

Main Features

MVC

Laravel uses the MVC model, therefore there are three core-parts of the framework which work together: models, views and controllers. Controllers are the main part where most of the work is done. They connect to models to get, create or update data and display the results on views, which contain the actual HTML structure of the application.

Routing & Middleware

You can define the URLs of your application with the help of routes. These routes can contain variable data, connect to controllers or can be wrapped into middlewares. Middelware is a mechanism for filtering HTTP requests. They can be used to interact with requests before they reach the controllers and can thus modify or reject requests.

Artisan

Artisan is the command line tool you can use to control parts of Laravel. There are a lot of commands available to create models, controllers and other resources needed for development. You can also write your own commands to extend the Artisan command line tool.

Eloquent ORM

To connect your models to various types of databases, Laravel offers its own ORM with a large set of functions to work with. The framework also provides migration and seeding and also features rollbacks.

Event Handling

The framework is capable of handling events across the application. You can create event listeners and event handlers that are similar to the ones from NodeJs.

Versions

VersionRelease Date
1.02011-06-09
2.02011-11-24
3.02012-02-22
3.12012-03-27
3.22012-05-22
4.02013-05-28
4.12013-12-12
4.22014-06-01
5.02015-02-04
5.1 (LTS)2015-06-09
5.22015-12-21
5.32016-08-24

Laravel 5.1 is the first release to receive long term support (LTS); it will receive bug fixes for 2 years and security fixes for 3 years.

Still have a question about Getting started with Laravel? Ask Question

Topic Outline