Download the PHP package darkorsa/cordo without Composer

On this page you can find all versions of the php package darkorsa/cordo. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package cordo

cordo

Cordo is a microframework designed for efficient development of REST APIs using principles such as:

It's compliant with PSRs: PSR-1, PSR-2, PSR-3, PSR-4, PSR-7, PSR-11, PSR-15, PSR-18.

Main goal to create this framework was to have an efficient tool to build API based applications with good architectural foundations and as little "magic" and configuration as possible.

Note: Cordo is still in development. Some of the basic features are implemented but tests are still missing. Please keep that in mind.

Requirements

Optional requirements

Install

To create a new project go to your project folder and within this folder type:

Next copy .env_example file and rename it to .env. Then fill it with your configuration data.

Optionally you can run console command:

It will create:

Still missing

How things work

Cordo does not reinvent the wheel. It's basically a set of popular PHP libraries put together and configured in order to create a simple framework that is in compliance with good programming practices for modern PHP.

Some of the used libraries:

This documentation does not focus on describing in detail how to deal with Routes, Command Bus, DI Container, querying DB, etc., for that use the documentation of the relevant library.

You are also encouraged to find for yourself how things work under the hood, check the Cordo Core library where abstract classes and interfaces are located.

If you want to see how the code can be organizen within all the layers, how to utilize of CQRS, Repository Pattern, Events, Queues, etc. take a look at the Users Bundle. Check the installation instructions here.

Entry points

Entry points to the application:

Web

Entry point for HTTP requests is public/index.php. Your apache/nginx configuration should point to the public folder.

Console

Command-line commands are handled with use of Symfony Console component.

You can fire your commands through the command-line with:

List currently registered commands:

Global commands should be registered in ./cordo file by adding them to the application object:

Feature commands should be registered in app/[Context]/[PackageName]/UI/Console/commands.php file.

Registering new package

This framework uses package by feature approach. It means that you organize your code in packages placed in app/ folder.

Just add your package folder name to the app/Register.php:

Once you package is registered, framework will have access to defined routes, DI container definitions, configs, commands, etc.

Package structure

Users package is shipped by default with implemented basic CRUD actions.

Here's how the code is organised:

This structure consists of layers: User Interface, Application, Domain and Infrastructure.

Important!

If you want to quickly boilerplate your new module there's a command for that:

you can find pre-prepared archive in app/resources/module.

That can save you a lot of time as this will generate the whole structure of folders and files for typycial CRUD.

Routes

Route definitons should be located at app/[Context]/[PackageName]/UI/Http/Route/[PackageName]Routes.php file. Routes loader class should inherit from abstract class Cordo\Core\Application\Service\Register\RoutesRegister.

Routing is done with use of FastRoute but modified allowing to use per route Middlewares.

Perferable way to generate API documentation is ApiDoc but that can be changed according to individual preferences.

Dependency Injection Container

DI Conteriner definitions should be placed in app/[Context]/[PackageName]/Application/definitions.php.

Cordo uses PHP-ID for DI Container, if you need to find out more check the documentation.

Config

Global config files should be located at config/ dir, while feature configs location should be: app/[Context]/[PackageName]/Application/config/

Config files should return PHP associative arrays. Multidimensional arrays are supproted.

Usage:

where "users" is the name of the config file and the following segments are array associative keys.

Database

Database configuration is located at bootstrap/db.php file. Framework uses Doctrine for database storage and object mapping.

According to the CQRS approach preferable way is to use Doctrine ORM for storing and Doctrine DBAL for querying.

Doctine is preconfigured to support UUID.

XML Mapping also is supported so you can map your Domain Models directly with database tables. You should place your mappings in app/[Context]/[PackageName]/Infractructure/Doctrine/ORM/Metadata/.

When you have your mappings ready you can create/update/drop schema directly from composer:

Mailer

For mail Laminas Mail is used. Currently there are 2 drivers for mail transport log (for development) and smtp. You can define your mail driver and credentials in config/mail.php file.

In order to add/change drivers you can just replace MailerFactory class with your own in bootstrap/app.php.

Internationalization

Translations are handled with Symfony Translations. Default file format for translations is Yaml.

You should place your translation files in app/[Context]/[PackageName]/UI/trans/ folder or subfolders. Naming convention is: [domain].[locale].yaml, for example: mail.en.yaml.

Usage:

You can set per request locale by adding &lang parameter to request uri or by adding --lang flag while running console command.

Config file for translations is located at config/trans.php.

Views

Plates is used as a template engine. Place your view files in app/[Context]/[PackageName]/UI/views/ folder or subfolders.

Usage:

Command bus

Cordo uses Tactician command bus for implementing Command Pattern.

Your Command -> Handler mappings should be placed in: app/[Context]/[PackageName]/Application/handlers.php file.

Command bus is configured to lock each handler in seperate transaction, it also supports events, queues, command logging. Check bootstrap/command_bus.php and Tactician documentation for details.

Events

In contrast to the Command -> Handler mapping where for one Command there can be one and only one Handler you can have several listeners for a single emmited event.

Your listeners definitions should be located at: app/[Context]/[PackageName]/Event/Loader/[PackageName]Listeners.php. Events loaders class should extend Cordo\Core\Application\Service\Register\ListenersRegister.

Here is how you can emit an event:

Define your listeners in app/[Context]/[PackageName]/Application/events.php file (see example in Users module):

Queues

For background processing Bernard library is used.

Currently supported drivers are:

The config file for queues where you can specify the driver to be used in your application is located here config/queue.php.

If you want to make your Command to be queued just make it implementing Cordo\Core\Application\Queue\MessageInterface interface or just extend Cordo\Core\Application\Queue\AbstractMessage class.

To launch background process that will process queued commands run in the console:

To better understand how to deal with events check Users Bundle module and see how welcome message is being sent for newly created users.

Note: if you'd like to use the Redis driver for queues make sure that you have Redis extension for PHP installed. You can install it from PECL repository:

OAuth2

This framework is shipped with OAuth2 as the default authorization method. OAuth2 servers configuration is located at: app/config/auth.php.

For real life OAuth2 implementation please check Users Bundle)

ACL

For the purpose of Authorization Zend ACL has been used. ACL roles, resources, permissions cen be defined seperately in each package in app/[Context]/[PackageName]/Application/Acl/[PackageName]Acl.php which should extend Cordo\Core\Application\Service\Register\AclRegister.

In Auth package that is shipped with Users Bundle there are CRUD actions prepared for users ACL rules.

Errors

By default all the errors are logged to the storage/logs/error.log file.

Additionally in dev environment errors will be prompth to the screen in pretty format using Whoops. Errors in console are also pretty formated. In production environment errors stack traces will be emailed to the addresses defined in config/error.php.

If you'd like to change any of that bevavior you can to it in: bootstrap/error.php file.

Credits

License

The MIT License (MIT). Please see License File for more information.


All versions of cordo with dependencies

PHP Build Version
Package Version
Requires darkorsa/cordo-core Version ~0.50.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package darkorsa/cordo contains the following files

Loading the files please wait ....