DEV Community

Lucas Carvalho
Lucas Carvalho

Posted on

The PHP Orkestra Framework

Introduction

Some months ago I started a side project aiming for study and personal use to create a new PHP framework capable to seamless integrate with wordpress as a plugin or to work fully autonomous. Based on PSR and best practicess, following SOLID and DRY principles at the best.

This last week I finaly ended the first version of the Orkestra framework core, with all critical components tested and working as expected.

As Matt Mullenweg said before, "code is poetry" and the Orkestra framework whas build to allow developers to create art expressed in if's and classes, leveraging the best in PHP ecossistem to allow you to conduct each small part of your software to work seamsly with other with nice and elegant structure.

The goal of Orkestra is to be high extensible, simple to work with and integrate with different environments as Wordpress (the reason that this first release does not includes a database ORM).

Why not just use Laravel?

Currently Laravel is the "go to" for new PHP applications to mostly developers today, if not, plain PHP, Slim, Symfony and other frameworks does the job, but for Wordpress, custom PHP boilerplates or/and outdated PHP patterns (aka, single ton) is what we have for work in mostly cases, if not, hacky ways to integrate frameworks as Laravel itself or parts of it to leverage a better code structure.

Orkestra itself does not contain WordPress connections, this part will be released soon with Orkestra WP, a package that will contain a proxy structure to easily convert a Orkestra application into a WordPress plugin just by changing the service providers.

So this framework is not builded to "replace" Laravel and other great options but to be a well structured, fast and light option to build well designed software for situations were a more lightweight and tailored solution is needed to fast develop. While Laravel and other frameworks offer robust features and extensive toolsets, they may be overkill for certain projects or keep their extensibility sourounded by their only ecosystem.

So how to start a new project?

To easily start a new project, we also have a skeleton that will initiate the codebase with just a few question and that will be incremented with time adding more templates as "react", "wordpress" and options containing datatbase ORM and user repositories which will allow you to easily launch more complex PHP applications in a standard way.

So to start you only need PHP 8.2+ and composer installed, then run:

composer create-project luccpl/orkestra-skeleton {project_name}
Enter fullscreen mode Exit fullscreen mode

Change {project_name} to your project name, then you just need to answer the questions to create your application.

After this you will end up with the following codebase inside the created directory:

Vanilla template structure

As you can see this template will add and configura the Pest test suite with a custom TestCase class that will start the application for your tests, making easy to test your application services (as used by Orkestra itself) and you will see a basic application, with a single route in the file config/routes.php that calls a Controller that simply render a Twig view.

Now you can go to the root directory in a terminal and run our CLI application to start the server on port :3000.

php maestro app:serve
Enter fullscreen mode Exit fullscreen mode

The Orkestra application start page

With this ready you can start building your application by following the documentation.

I recommend you to also follow a repository pattern in your application, to keep best principles and your application easy to mantain and use our Orkestra\Entities\AbstractEntity and the Orkestra\Entities\EntityFactory.

Conclusion

Orkestra presents a fresh approach to PHP development, offering a seamless integration with WordPress on the horizon. While not aiming to replace established frameworks like Laravel, it provides a lightweight, extensible solution for projects where a tailored, efficient codebase is preferred.

Starting a new project is made simple with the Orkestra skeleton, initiating you with a clean structure and options for further customization.

Thanks for reading and see you in next updates.

Top comments (0)