fuelphp support and use of composer packages

Source: Internet
Author: User
Tags autoloader json

There have been a lot of recent discussions about PSR-1, Composer, packagist packages, and whether or not fuelphp supports these, and I'm going to make a clear standard on fuelphp support Composer to understand how to use it now, And how it will be used in the future.

Can I use composer package management now?


the answer is "Yes, absolutely!" "

In fact, the composer itself is not used in the 1.x version of fuelphp, which does not mean that you cannot add the composer package to your application. So how do you get composer packages into your project? Quite simply, follow these steps:

1. Install composer package to your AppPath (not the item's more directory), you can view the introduction here (HTTPS://GETCOMPOSER.ORG/DOC/00-INTRO.MD)

2. Create a Composer.json file, this file will install the package you choose, you can see the documentation here: Https://getcomposer.org/doc/01-basic-usage.md#composer-json-project-setup

3. Run the composer installer to install the dependencies in your Composer.json file.

When this is done, composer has been installed in the "Vendor" folder of your application directory, which will exist in each fuelphp default installation.


The next step is to set your dependencies in the frame, and the process needs to operate on its own, because the framework does not automatically load composer, it uses its own built-in PSR-1 loader, and here's what it does: in your bootstrap.php, in code:

Autoloader::register ();

Add back

Load the Composer autoloader 
require apppath. ' vendor/autoload.php ';

This will load the composer loader, which will be used when the fuelphp built-in loader cannot find the calling class. From now on, you can use the packages that have been loaded and installed in your application, just like any class.


What about the future?

Fuelphp the second version will be a complete composer build, included in the application, you can view the repository of the current framework: https://github.com/fuelphp/fuelphp, now in v2 development, We will use Packagist repository in our composer packages.

We have not discussed what will be done in the 2.0 release, especially when it comes to some fuelphp specific packages. Those using packagist may be simpler and more convenient to operate, and on the other hand, a fuelphp-specific package repository may be more accessible to the framework user. Let us know more about your thoughts!



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.