Refuse to reinvent the wheel, use composer to build your own framework (1)

Refuse to reinvent the wheel, use composer to build your own framework (1)

"The era of Composer dominating the world has arrived!" 』——Bai Yansong

"Composer will be the mainstream of PHP in the future! 』——Ma Yun

"Programmers who don't know how to package management will be eliminated!" "--Nearly flat

『Let’s learn composer to build a framework! 』——Li Wenkai

"One era is over, another era begins."

The Framework Interoperability Group, referred to as FIG, was established in 2009. FIG was originally initiated by several well-known PHP framework developers. After absorbing many excellent brains and strong physiques, FIG proposed five unofficial PHP specifications from PSR-0 to PSR-4:

1. PSR-0 (Autoloading Standard)

2. PSR-1 (Basic Coding Standard) basic coding standard

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

4. PSR-3 (Logger Interface)

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

After that, on top of this standard, Composer turned out! Composer uses PSR-0 and PSR-4 as well as the PHP5.3 namespace to construct a prosperous PHP ecosystem. Composer is similar to the famous npm and RubyGems, and provides a very convenient collaboration channel for massive PHP packages. Composer Hub address: . Composer Chinese website: .

At present, Laravel and Symfony, which are in the PHP world, are directly based on Composer. Everybody is familiar with the well-known frameworks CI and Yii. The development versions of CodeIgniter 3 and Yii 2 are also based on Composer (update: Beijing time October 13, 2014 Yii 2 has been released ). Composer is the future of the PHP framework. With it, the collaboration between CI routing and Laravel's Eloquent ORM will become very simple.

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

php composer.phar update

Call directly.

Create a new folder in a suitable place, name it MFFC (My First Framework based on Composer), and create a new file composer.json under the folder:

{"require": {}}

Switch to the MFFC directory from the command line and run:

composer update

After a while, the following files and folders will appear:

If the above content appears successfully, congratulations, Composer has been initialized successfully!

Reference: Refuse to reinvent the wheel, use composer to build your own framework (1)-Cloud + Community-Tencent Cloud