The PHP Orkestra Framework
Tags: php, news, orkestra, opensource
Published: 2024-05-06 02:05:53

## 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](https://www.php-fig.org/psr/) and best practicess, following [SOLID](https://en.wikipedia.org/wiki/SOLID) and [DRY](https://en.wikipedia.org/wiki/Don%27t_repeat_yourself) principles at the best.

This last week I finaly ended the first version of the [Orkestra framework](https://packagist.org/packages/luccpl/orkestra) 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](https://en.wikipedia.org/wiki/Object%E2%80%93relational_mapping)).

## Why not just use Laravel?

Currently [Laravel](https://laravel.com/) is the "go to" for new PHP applications to mostly developers today, if not, plain PHP, [Slim](https://www.slimframework.com/), [Symfony](https://symfony.com/) and other frameworks does the job, but for Wordpress, custom PHP boilerplates or/and outdated PHP patterns (aka, [single ton](https://refactoring.guru/design-patterns/singleton)) is what we have for work in mostly cases, if not, hacky ways to integrate frameworks as [Laravel itself](https://roots.io/acorn/) 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](https://github.com/Luc-cpl/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:

```bash
composer create-project luccpl/orkestra-skeleton {project_name}
```

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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ngalxgrgtwzferaoy1ov.png)

As you can see this template will add and configura the [Pest](https://pestphp.com/) 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](https://twig.symfony.com/) view.

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

```bash
php maestro app:serve
```

![The Orkestra application start page](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/efsins6qsoo825td45cp.png)

With this ready you can start building your application by following the [documentation](https://github.com/Luc-cpl/orkestra/wiki).

I recommend you to also follow a [repository pattern](https://blog.mnavarro.dev/the-repository-pattern-done-right) 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.