最近有许多关于PSR-1, Composer, Packagist packages的讨论,同样是否FuelPHP是否支持这些,这篇文章我将制作一个清晰的关于FuelPHP支持Composer的标准,了解现在如何使用它,并且未来将如何使用。
我现在可以使用composer包管理么?
这个答案是“可以,绝对的!”
事实上在1.x版本的FuelPHP中没有使用Composer本身,这并不意味着你不能将composer包加入到你的应用中去。所以,你如何将composer包引入到你的项目中去?很简单,跟着下面几个步骤来操作:
1.安装composer包到你的APPPATH(不是项目的更目录),可以查看这里的介绍(https://getcomposer.org/doc/00-intro.md)
2.创建一个composer.json文件,这个文件将会安装你选择的包,可以看这里的文档:https://getcomposer.org/doc/01-basic-usage.md#composer-json-project-setup
3.运行Composer安装器来安装你composer.json文件中的依赖关系。
这些完成后,Composer已经安装到你应用目录"vendor" 文件夹中去了,这个在每个FuelPHP默认安装中都会存在。
下面一个步走就是在框架中设定你那些依赖,这个过程需要自己操作,因为框架不会自动加载Composer,它使用自己内置的PSR-1 自动加载器,下面来做这些:在你的bootstrap.php,在代码:
<span style="font-family: 'Comic Sans MS', cursive;"><span style="font-size: 14px;">Autoloader::register();</span></span>
后面增加
<span style="font-family: 'Comic Sans MS', cursive;"><span style="font-size: 14px;">// load the Composer autoloader require APPPATH.'vendor/autoload.php';</span></span>
这个将会载入Composer自动加载器,这个将会在FuelPHP内置加载器无法找到调用类的时候使用。从现在开始,你可以在你的应用中使用已经被加载安装好的包了,就像任何类一样。
未来如何?
FuelPHP第二个版本将会将会建立完全的Composer组建,包含在应用程序,你可以查看现在框架的存储库:https://github.com/fuelphp/fuelphp,现在正在v2的开发中,我们将在我们composer packages中使用Packagist repository。
我们没有讨论在2.0发布版中将要做什么,特别是当他涉及到一些FuelPHP特定的包。那些使用Packagist的,可能是为了操作变的更简单和更方便,另外一方面,一个FuelPHP特定包存储库可能更容易接近框架用户。让我们知道你更多的想法!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Atom editor mac version download
The most popular open source editor

SublimeText3 Linux new version
SublimeText3 Linux latest version

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

Zend Studio 13.0.1
Powerful PHP integrated development environment

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.