Chapter 5. Packages

In the previous chapter, we used packages to make our lives easier. We used Oil to quickly get up and running, as well as the Auth package that helped with user authentication.

In this chapter, we will cover the following topics:

  • What is a package?
  • Recommended packages
  • Working with the Auth package for user authentication
  • What is Composer and how to use it?
  • An introduction to building your own package

What is a package?

As developers, we often have code that we use on multiple projects. It could be as simple as string manipulation, but we would be lost without the code we are familiar with.

This is where packages come in useful. They give a great way of organizing, re-using, and sharing your code. Packages can contain all sorts of code, such as models, configurations, and even third-party libraries.

Due to the class structure of FuelPHP and other packages, it's possible to extend other packages and to the FuelPHP core. This is all possible without changing the core files—making upgrades easier and more straightforward.

Although there is a lot that packages can do, there are some things that packages can't do. For example, they can't map to a URL; this is the role of the application or project code. If there is a functionality that you'll re-use in multiple projects and which also requires URL access, it is recommended to use modules. These will be introduced in the next chapter.

Running through some recommended packages is a great way to demonstrate what is possible when using packages.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.221.154.18