THINKPHP5 development environment Installation and configuration ____php

Source: Internet
Author: User
Tags php framework readfile traits git clone
I. Purpose of the experiment

1, Master ThinkPHP5 (abbreviation TP5) development environment installation and configuration. Ii. content of the experiment

1, Master APPSERV development environment installation.
2, Master TP5 development environment installation.
3, Master Composer Development environment installation. Iii. Experimental Steps and Processes 1. Environmental Requirements

We chose to learn the development of THINKPHP5 under the WIN8 operating system, as shown in the following table:

Tools Description
Appserv [https://www.appserv.org/]
THINKPHP5 Application Project [Https://github.com/top-think/think]
THINKPHP5 Core Framework [Https://github.com/top-think/framework]
Composer [https://getcomposer.org/]

Detailed description as follows: Appserv-appserv:apache + PHP + MYSQL
Current Appserv Latest Version: Appserv 8.6.0, released in 2017-01-25, has the following characteristics:

-Apache 2.4.25
 -php 5.6.30
 -php 7.1.1
 -MySQL 5.7.17
 -phpMyAdmin 4.6.6
 -Support Tls,ssl or https< c5/>-Can Switch The PHP version as you need.
2, Appserv installation

The installation process is shown in the following illustration, including Apache, PHP, and MySQL installations.
  

  

  

  

  

  

  

After the installation is successful, enter localhost in the browser, and the following home page pops up, indicating that the installation was successful.

   3, composer installation 3.1 Composer Introduction

Composer is a dependency management tool for PHP. It allows you to affirm the code base on which the project depends, and it will install them for you in your project.

Dependency Management

Composer is not a package manager. It involves "packages" and "libraries", which are managed on a per-project basis and installed in a directory of your project (for example, vendor). By default, it does not install anything on the global. So, this is just a dependency management. Composer was strongly inspired by node ' NPM and Ruby's bundler. And there was no such tool under PHP.

Composer will solve this problem for you:

A You have a project that relies on a number of libraries.

b Some of the libraries are dependent on other libraries.

c You declare what you depend on.

D Composer will find out which version of the package needs to be installed and install them (download them to your project).

declaring dependencies

For example, you are creating a project and you need a library to do the logging. You decide to use Monolog. To add it to your project, all you have to do is create a Composer.json file that describes the dependencies of the project.

{
    "require": {"Monolog/monolog":
        "1.2.*"
    }
}

We simply point out that our project requires some monolog/monolog packages, starting with any version from 1.2. 3.2 Installation Process

Using the Setup program

This is the easiest way to install Composer on your machine. Download and run Composer-setup.exe[https://getcomposer.org/composer-setup.exe], it will install the latest version of the Composer, and set the system environment variables, So you can use the composer command directly in any directory.

Manual Installation

Set the system's environment variable PATH and run the install command to download the Composer.phar file:

$ C:\USERS\USERNAME>CD C:\bin
$ c:\bin>php-r "ReadFile (' Https://getcomposer.org/installer ');" | php

Note: If you receive the ReadFile error prompt, use the HTTP link or open Php_openssl.dll in php.ini.

Create a new file in the Composer.phar sibling Composer.bat:

C:\bin>echo @php "%~dp0composer.phar"%*>composer.bat
3.3 Test Installation Success

Close the current command Line window and open a new command line window to test:

C:\users\username>composer-v
Composer Version 27d8904
4, ThinkPHP5 installation

Strictly speaking, ThinkPHP5 do not need to install the process, here is the installation is to put the thinkphp framework into the web running environment (if your Web run environment is OK). There are several ways to get and install thinkphp. 4.1 TP5 Three ways to install

Download and install the website

There are many ways to get thinkphp, and the official website (http://thinkphp.cn) offers a stable version or a full version of the download. Note: The download version of the official website is not necessarily the latest version, the git version gets the version that keeps the update.

Composer installation

If Composer is already installed, you can update Composer to the latest version with the Composer self-update command. Then, under the command line, switch to the bottom of your Web root directory and execute the following command:

Composer Create-project Topthink/think Tp5--prefer-dist

git installation

TP5 split into multiple warehouses, mainly including:

--Application project: Https://github.com/top-think/think

--Core framework: Https://github.com/top-think/framework

First clone download Application project Warehouse

git clone https://github.com/top-think/think tp5

Then switch to the TP5 directory and clone the core framework warehouse:

git clone https://github.com/top-think/framework thinkphp

After the two warehouse clones are complete, the ThinkPHP5.0 git download is complete, and if the core framework needs to be updated, just switch to the thinkphp core directory and execute:

Git pull Https://github.com/top-think/framework
4.2 ThinkPHP5 FrameworkTP5 Download Complete directory:
``
├─application application Directory
├─extend Extended Class Library directory (customizable)
├─public website External Access Directory
├─runtime Runtime directory (customizable)
├─vendor third-party Class library directory (Composer)
├─thinkphp Framework Core Catalogue
├─build. PHP automatically generate definition file (reference)
├─composer.json Composer Definition File
├─license.txt Authorization Note File
├─README.MD Readme File
├─think Command line tool entry
* The structure of the core framework directory is as follows: 
  '
├─thinkphp Framework System directory 
│├─lang Language Pack directory 
│├─library Framework core Class Library directory 
││├─think the library directory 
  ││└─traits System Traits Directory 
│├─TPL system template directory 
│├─.htaccess rewrite 
│├─.travis.yml CI definition file for Apache │├─base.ph 
P Framework base file 
│├─composer.json composer definition file 
│├─console.php Console portal File 
│├─convention.php Convention profile 
│ ├─helper.php helper function file (optional) 
│├─license.txt authorization description file 
│├─phpunit.xml Unit Test Profile 
│├─readme.md README file 
│ └─start.php Framework Boot File
4.3 ThinkPHP5 entry file index.php

Index.php is in the public directory. In thinkphp, edit the application entry files by default settings, including defining application portals and loading framework boot files, and note the directory structure of the files. The current index.php file is in the public directory, as shown below.

<?php
//[Application entry file]
//define application directory
define (' App_path ', __dir__. '/.. /application/');
Load frame boot file
require __dir__. '/.. /thinkphp/start.php ';

If the system installation directory is TP5, enter the browser-side: http://localhost/tp5/public/
You can see the Welcome page:
  

Congratulations. The environment has been installed and can be developed for formal software projects.

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.