Laravel Framework Learning (I.)

Source: Internet
Author: User
Tags php web development

First, the initial knowledge laravel

1. Encyclopedia describes: Laravel is a set of concise, elegant PHP Web development Framework (PHP Web framework).

2. Source: Official website http://www.golaravel.com/

Laravel College: http://laravelacademy.org/

3. Build a laravel framework of your own

Laravel uses Composer (Composer Chinese) to manage its own dependency packages. Therefore, before using Laravel, make sure that you have installed the Composer on your machine.

(1). What is composer?
is the tool that PHP uses to manage dependency (dependency) relationships. You can declare your dependencies on the External tool Library (libraries) in your project, and Composer will help you install these dependent library files.
(2). Website: https://getcomposer.org
Download: https://getcomposer.org/download/

China full-scale mirror: http://pkg.phpcomposer.com/
Enable this mirroring service command:
Composer Config-g Repo.packagist composer https://packagist.phpcomposer.com
Or
Composer Config Repo.packagist composer https://packagist.phpcomposer.com
(3). Composer Common commands:
Composer-v View Version
Composer SelfUpdate Update composer

Installing the Laravel Framework

Operating Environment requirements:-PHP >= 5.5.9

-OpenSSL PHP Extension

-PDO PHP Extension

-mbstring PHP Extension

-Tokenizer PHP Extension

Under DOS move to project directory, install Laravel by Composer create-project command:
Command: Composer Create-project Laravel/laravel--prefer-dist

Wait for the installation to finish, we have a laravel frame!!!

Second, a simple understanding of the application structure

/root directory

/.env Framework configuration file, generally do not directly modify the configuration file directory configuration, through this configuration file to modify the configuration

The/app directory contains the core code of the application

/app/http/routes.php Routing Files

/app/http/controllers Controller Directory

The/bootstrap directory contains several files for starting the framework and configuring the auto-load feature, as well as a cache directory to hold automatically generated files for the framework to speed up the framework startup.

The/config directory contains the configuration files for all applications

The/database directory contains database migration and data population files

The/resource directory contains your views, the original resource files (less, SASS, Coffeescript), and the localized language files.

/resource/views Template Catalog

The/storage directory contains the compiled Blade template, the file-based session, the file cache, and other files generated by the framework. This directory contains three subdirectories: app, framework, and logs. The app directory user holds any

The framework directory is used to hold the files and cache files generated by the frame; Finally, the logs directory is used to store the application's log files

The/test directory is used to store your automated test files. The Laravel default comes with an instance of PHPUnit.

/vendor directory is used to store the Composer dependency package

Three, virtual host configuration

1. Local domain name resolution and Apapche Virtual Host Configuration (window)

(1) Open: Hosts file in the C:\Windows\System32\drivers\etc directory:
Configuration information: 127.0.0.1 www.laravel.com

(2) Configure in Apache's httpd-vhosts.conf configuration file

<virtualhost *:80>
ServerAdmin [email protected]
DocumentRoot "E:/wamp/www/laravel/public"
ServerName www.laravel.com
Errorlog "Logs/www.laravel.com-error.log"
Customlog "Logs/www.laravel.com-access.log" common
</VirtualHost>

Iv. Access Process

1. Successful installation Laravel the framework directly accesses the configured virtual host via the browser http://www.laravel.com or direct access http://localhost/laravel/public/this will present Laravel 5

This access is directly loaded through the route view, without passing the controller.

2.Laravel can also print text directly to the page via routing (not recommended)

To add a new route to the route file:

1 /* access to the Www.laravel.com/hello even view is not passed */ 2 // Normal Routing 3 function () {4     return "Hello world! \ n Generate the URL address ". URL ("/hello "); 5 });
View Code

3. Calling methods in the controller through routing

1 // Demo Test Route exit 2 Route::get ("demo", "[email protected]");
View Code

Laravel Framework Learning (I.)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.