Laravel PHP Framework Usage write the first Hello World,laravel getting started configuration

Source: Internet
Author: User
Tags autoload install php php class php framework redis composer install

Laravel first use, how to write the first Hello World

Laravel PHP Framework First Contact, encountered some difficulties, here to record, the need for children's shoes can look

Download the latest version from GitHub, address as follows

Https://github.com/laravel/laravel

I chose the download zip, downloaded to the desktop, and then put it into an Apache virtual directory, and then access, this directory, the result is wrong, this error has two reasons

The first reason is that PHP version should be more than 5.3, because more than 5.3 to resolve __dir__

__dir__. ' /bootstrap/paths.php '
The second path is wrong, and the path to the virtual directory points to the extracted public directory, which is correct

Then I do an example in the document, the first example is the route example, written in app/routes.php, in this directory, the code is as follows

Route::get (' Users ', function ()
{return
    ' users! ';
});

Then I visited the local address: Http://192.168.0.89:5605/users is wrong, and then found that the Laravel framework is not simply decompression is done, is required to install the specific installation method

This is true (search "Windows Install PHP Dependency management tool Composer" can be found, the original link is as follows

Http://www.kankanews.com/ICkengine/archives/19110.shtml

After the installation is completed, a vendor directory is added, and no other changes have been found.

Once the installation is complete, visit http://192.168.0.89:5605/users again, which is normal.



In order to prevent link invalidation I copied his article and put it down below,

So how do I install composer under Windows?

Windows executes commands in a way that is less convenient than Linux. So we have to set the PHP environment variable first, so that PHP can run through DOS.

1. My Computer (right key)-> Properties-> advanced system Settings-> advanced-> environment variables, select Path, edit, append later

;D: \xampp\php

Alt+r->cmd opens the DOS window and executes the php-v. If the middle error, prompted a series of DLLs not found, modify the php.ini,

The value of the Extension_dir, set to absolute path, Extension_dir = "D:\xampp\php\ext", I've got a browscap.dll. Error message not found, find the Browscap in php.ini, and change its value to the value of an absolute path

If you don't make a mistake. To perform php-v, you should get the following results:

2. Open SSL Extension

Modify php.ini, open extension = Php_openssl.dll

3. Go to php directory and execute PHP command.

Here we recommend that you modify the form of the registry, you can enter the file on the right click, directly into the file cmd command, rather than every time to perform cd/d D:/xampp/htdocs

Create a new file and paste the code:

Windows Registry Editor Version 5.00
[Hkey_classes_root\folder\shell\cmd]
@= "cmd fast Channel"
[Hkey_classes_root\folder\shell\cmd\command]
@= "cmd.exe/k CD%1″

Save As Xx.reg, run, click Yes, and then find a folder, right click, you will see a CMD fast access to the operation of the

Back to the point: Enter into the project file Htdocs, input in DOS

Php-r "eval ('?> '. file_get_contents (' Https://getcomposer.org/installer '));"

Wait a moment and you will see the following tips:

4. In your project file, create a new Xx.bat file, edited as follows:

@ECHO off
SET subdir=%~dp0
PHP%subdir%\composer.phar%*
Then do it. This file is to define the current path as composer and, of course, you may not execute the file.

5. Here, the composer is basically installed. So next we're going to install the expansion pack,

Open the Composer.json in Htdocs and enter the extensions we want to install:

The format is roughly as follows:

{
"Require": {
"Chrisboulton/php-resque": "1.2″,
"lisachenko/go-aop-php": "*",
"Monolog/monolog": "1.2.*"
}
}

6. If the fourth step is executed, execute the composer install directly under the Htdocs directory

If you do not perform the fourth step of the file, you will need the PHP Composer.phar install

OK, the installation is done here, the expansion package, also downloaded well. Htdocs will have a vendor folder, open will find that more than Chrisboulton,lisachenko,monolog three folders. Now look at the automatic loading bar ...

We need to use the expansion pack again, require_once Root_path. ' vendor/autoload.php ';

You can then call the class name in the expansion package directly.

Examples are as follows:

<?php

Require_once Root_path. ' vendor/autoload.php ';//root_path is the root directory

$redis = Resque::redis ()//here directly invokes the Vendor/chrisboulton/php-resque/lib/resque.php class name without introducing the file

Var_dump ($redis);

This redis variable is a Redis class of Php-resque.

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.