Basic preparation for building your PHP framework with Composer and building with composer

Source: Internet
Author: User
Tags autoload php development environment php framework

Basic preparation for building your PHP framework with Composer and building with composer

"The era of Composer unified the world has arrived !』

-- Bai yansong

"One era is over and the other is over ."

Framework Interoperability Group (Framework Interoperability Group), FIG for short, was established in 2009. FIG was initially initiated by several well-known PHP framework developers, in absorbing a lot of excellent brain and strong body, proposed PSR-0 to PSR-4 five sets of PHP unofficial specifications:

1. PSR-0 (Autoloading Standard) Automatic Loading Standard

2. PSR-1 (Basic Coding Standard) Basic Coding Standard

3. PSR-2 (Coding Style Guide) Coding Style wizard

4. PSR-3 (Logger Interface) log Interface

5. PSR-4 (Improved Autoloading) automatic loading optimization Standard

Then, above this standard, Composer was born! Composer constructs a prosperous PHP ecosystem using PSR-0 and PSR-4 and the namespace of PHP5.3. Similar to the famous npm and RubyGems, Composer provides an extremely convenient collaboration channel for massive PHP packages. The Composer Hub address is https://packagist.org /. Composer Chinese website: http://www.phpcomposer.com /.

Currently, Laravel and Symfony, which are popular in the PHP field, are both directly based on Composer. We are familiar with the well-known frameworks CI and Yii, whose development versions CodeIgniter 3 and Yii are both based on Composer (Updated: yii 2, January 1, October 13, 2014, Beijing time ). Composer is the future of the PHP framework. With it, CI routing and Laravel's Eloquent ORM collaboration will become very simple.

The PHP language has powerful network functions, file management functions, and rich system APIs. Composer is just a PHP script. Available

php composer.phar update

Direct call.

Create a folder named MFFC (My First Framework based on Composer) in the appropriate place and create the file composer. json in the folder:

{ "require": { }}

Switch the command line to the MFFC directory and run:

composer update

Wait a moment and the following files and folders will appear:



If the above content appears successfully, congratulations, Composer Initialization is successful!


PHP composer basic usage Problems

Question 1: Why must I use manager as capsule?

The name is too long, so it is easy to rename it.

Question 2: What is the function of autoload. php under vendor? I want to know how to load it automatically.

Require '../vendor/autoload. php ';
The code of this file cannot be seen, so I don't know what he is doing.

Question 3: What is the function of bootEloquent ()?

I didn't see where to define this function, so I couldn't judge the function.
 
I want to build my own php development environment. What is the common framework + template engine in the industry?

Mysql + php + apache, the template is smarty, simple and easy to use.

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.