Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Building library
  • Hello. How can I build something like library in FuelPhp as/like C++ .h files and use it everywhere in my project. How to use my own classes in FuelPhp with Controller or Model? Traits? Classes can extend only one class. Namespaces? I am new to FuelPhp and namespaces. Give me good tutorials for advanced namespacing. What do I need to know before to start using FuelPhp? Give me something that I need to know about programming with FuelPhp to start effective programming. Thank you.
  • HarroHarro
    Accepted Answer
    Namespaces and traits are generic PHP, and not specific to FuelPHP. So you can read anything you like.

    With regards to external classes, Fuel supports everything Composer can throw at you (just add it to the composer.json and run an update), and you can put any class in the classes folder of your application, and providing it follows the Fuel naming conventions, it will just load.

    As of 1.7.2, you can use the import() function to load classes that are not compliant, and you can also put external classes into the vendor folder of your app and use import() to load them.

    FuelPHP doesn't care if a file contains a class, an interface or a trait. Just follow the naming conventions for class and file names and it will just work.

    As to "libraries", FuelPHP support two forms of modular extensions.

    The first one, a "module", provides modular extension of your application. It can contain everything you app can contain, and it uses a base namespace for all files equal to the module name (= the folder name, ucfirst). If you write your modules without dependencies (loosly coupled), you can re-use then in every future application.

    The second one, a "package", provides modular extension of the framework. It can not contain controllers, models or viewmodels/presenters, but it can contain any other class, enhancing the functionality of the framework. Some of them are included, like Orm or Auth, you can find lots at http://github.com/fuel-packages, and there are more available if you google (or in the code share forum here).

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion