Home  >  Article  >  Backend Development  >  Basic preparation for building your own PHP framework with Composer, composer construction_PHP tutorial

Basic preparation for building your own PHP framework with Composer, composer construction_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 10:15:37861browse

Basic preparation for building your own PHP framework using Composer, composer construction

『The time for Composer to dominate the world has arrived! 』

——Bai Yansong

“One era ends and another begins.”

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

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 Guide

4. PSR-3 (Logger Interface) log interface

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

Afterwards, based on this standard, Composer was born! Composer utilizes 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, providing an extremely convenient collaboration channel for massive PHP packages. Composer Hub address: https://packagist.org/. Composer Chinese website: http://www.phpcomposer.com/.

Laravel and Symfony, which are currently popular in the PHP industry, are both directly based on Composer. The well-known framework CI and Yii’s current development versions CodeIgniter 3 and Yii 2, which everyone is familiar with, are also based on Composer (update: Yii on October 13, 2014, Beijing time 2 has been published). Composer is the future of the PHP framework. With it, it will be very simple to collaborate between CI routing and Laravel's Eloquent ORM.

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

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 on the command line and run:

composer update

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



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

Some basic usage issues of PHP composer

Question 1: Why must we use manager as capsule

Because the name is too long, so rename it to make it easier to use

Question 2: What is the function of autoload.php under vendor , let alone automatic loading, I want to know how to load it

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

Question 3: What is the function of bootEloquent()

I didn’t see where this function is defined, so I can’t judge its function

I want to build my own PHP development environment. What framework + template engine are common in the industry?

mysql+php+apache, use smarty for the template, it is simple and easy to use.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/903484.htmlTechArticleBasic preparation for building your own PHP framework with Composer, composer building "The era of Composer dominating the world has arrived!" 』——Bai Yansong “One era ends, another begins...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn