What is the Joomla Framework and how can you use it?
When people think of Joomla, they often think about the Joomla CMS, which is a great system for building websites. But Joomla is more than only the CMS. Under the hood, there is something else: the Joomla Framework.
The Joomla Framework is a group of separate PHP parts. You can even use them outside Joomla CMS! For example in custom apps, CLI tools, microservices, or other PHP projects.
Joomla Framework Packages
The Joomla Framework is modular. It means it has many small packages. Each one does one job. For example:
- Database connection
- HTTP handling
- File system functions
- Event system
You can use each of them on its own. You don’t need the full Joomla CMS. You can install these with Composer from Packagist. For example, use only the Joomla Database package in a Symfony or Laravel project. No need to install Joomla CMS.
PHP Libraries
When you develop code in PHP, you don't have to write everything from scratch. For instance, you might want to export data to a PDF. Don't re-invent the wheel and program your own PDF library but use an existing one instead. You can use "composer" to integrate PHP libraries made by others into your own projects. These libraries are tested and updated.
Packagist.org
For PHP library packages there is a website called Packagist. You can find all kind of packages there, including Joomla packages. Just search for https://packagist.org/?query=joomla.
Composer
Composer is the tool to manage PHP packages. It helps you install libraries. Just use:
composer require joomla/http
Composer will download the right version to a folder called /vendor/ . It also handles other needed packages and it sets up autoloading for you. In your PHP file you just use the following to load all libraries:
require __DIR__ . '/vendor/autoload.php';
Libraries Inside Joomla
Joomla uses its own Framework packages, and other PHP libraries too. These are already included in Joomla in the folder /libraries/vendor/
You don’t need to update them yourself. Actually, you should not update them yourself! Because that could make the Joomla base CMS different and when it causes errors, it would be difficult to solve. Joomla developers maintain the packages in /libraries/vendor/ for you. When they create Joomla install and update packages, they will include those libraries too. Safe and easy.
Using PHP Libraries in Your Own Extension
If you build your own extension, you can use composer too to use extra PHP libraries. But don’t put them in Joomla's /libraries/vendor/ folder!
That folder is managed by Joomla and can be overwritten with updates. Instead, put libraries in your extension folder: /components/com_mycomponent/vendor/
That way you control the version and also avoid conflicts with Joomla or other extensions.
Using Joomla Framework Packages Without Joomla CMS
Actually, for small projects you might not need the full Joomla CMS. You might use some PHP together with just some Joomla Framework packages. Go to Packagist, find a package, install with Composer:
composer require joomla/registry
In your PHP code:
require DIR . '/vendor/autoload.php';
use Joomla\Registry\Registry;
$registry = new Registry;
$registry->set('welcome', 'Hello Joomla world!');
echo $registry->get('welcome'); // Hello Joomla world!
Simple and clean.
Example: Display Joomla Articles Headless using the Joomla Framework
To demonstrate how to use the Joomla Framework, I created an example to display articles from a specific category in a standalone PHP application, without using the full Joomla CMS: https://github.com/pe7er/db8-joomla-framework-example
The code uses Joomla's database package to connect to an existing Joomla database and fetch content directly, which is very nice for headless or microservice-style use cases. My example focuses on using Joomla Framework directly, without relying on Joomla’s Web Services API or the CMS environment.
Features
- Headless: No Joomla CMS installation required
- Uses Joomla Framework packages via Composer
- Pulls articles from the #__content table
- Responsive HTML output using Bootstrap 5
- Easy to configure and extend
Requirements
- PHP 8.1 or higher
- Composer
- An existing Joomla 4.x or 5.x database
- Web server with index.php accessible
Installation
- Clone the repository:
git cloneEsta dirección de correo electrónico está siendo protegida contra los robots de spam. Necesita tener JavaScript habilitado para poder verlo. :pe7er/db8-joomla-framework-example.git
cd db8-joomla-framework-example - Install dependencies with Composer:
composer install - Configuration
Copy the .env.example to .env and change the database credentials
Use
- After configuring, run the app by opening index.php in your browser (via a local server like Apache or PHP's built-in server):
php -S localhost:8000 - In a browser visit: http://localhost:8000
You should see a Bootstrap-styled list of articles from your Joomla database.
Sample Image
My simple code example uses Joomla Framework Packages to retrieve articles from a specific category from a Joomla database. In my test environment the category contained 8 Joomla articles and would be displayed like this:
Joomla Framework References
- Website: https://framework.joomla.org/
- GitHub Project: https://github.com/joomla-framework
- Packages on Packagist: https://packagist.org/?query=joomla
Conclusion
The Joomla Framework is a powerful hidden secret, yet unknown to many developers. If you make Joomla extensions — or even just PHP apps — you can use these packages. It saves time. It makes your code better.
All you need is Composer… and a bit of curiosity.
Helping out with Joomla Framework?
If you want to help to improve the Joomla Framework:
- we need volunteers to improve the documentation for Joomla Framework
- we need more developers to improve and maintain the Joomla Framework packages
Some articles published on the Joomla Community Magazine represent the personal opinion or experience of the Author on the specific topic and might not be aligned to the official position of the Joomla Project
By accepting you will be accessing a service provided by a third-party external to https://magazine.joomla.org/
Comentarios 1
Hello
I have a contact with a former Joomla developer, and I asked him if it was possible to retrieve articles by date.
He looked, but it seems there's no filtering available at the moment. Can you confirm?
Regards