Download the PHP package tavrin/sirius without Composer

On this page you can find all versions of the php package tavrin/sirius. 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 sirius

Sirius

A PHP backend framework inspired by Symfony and Doctrine, currently in active development

Setting up index.php

To be used, the framework needs to be integrated into the index.php file, the environment variables need to be loaded and the ROOT_DIR constant needs to be defined, here is a simple example of its implementation :

Creating routes

Routes need to be set up in the config folder as a JSON file named routes.json, in this json file the routes need to be set up as objects inside an array, with the following elements :

Here is an example with several routes :

Routes can have wildcard parameters in their path, which need to be set in between brackets. Those wildcars can then be used as arguments for the associated controller method :

example of a path with several wildcard parameters (category and slug)

Controllers

Controllers are the endpoints of the routes, they can have the Request as well as the Wildcard parameters as arguments.

They are where the request is processed and where a Response needs to be returned. Generally this is either a rendered html page (from a Twig file) with a parameters array, a JON response, or a redirect.

Response types

Rendering in HTML : To render in HTML, the Controller method render() needs to be called, there are two parameters to pass, a link from the templates directory to the correct Twig template file, as well as an optional parameters array, which will pass data which can be reused in the associated template.

Sending a JSON response : To send a JSON response, the method sendJson (which contains two parameters, a data array and an optional status array with a 200 default value).

Sending a JSON response : Redirectionc can also be made from the controller, the redirect method needs to be called, an url needs to be passed, an optional flash message can also be passed in an array, with the 'type' parameter, which can be anything (generally success or danger/error) and the 'message' parameter, which is the flash message.

Most important methods

The abstract controller has several usable methods which are important to know about :

Database and Entities

For the database, first of all a database URI needs to be provided, this URI is then parsed and called inside the framework with PDO, an abstraction layer is then added on top of it, with a Doctrine inspired Entity system. The three major parts of an entity is the Entity class, the associated repository, and the associated JSON config file which contains all the needed information about the entity. The EntityManager class (which can be called in controllers with $this->getManager()) is the "brain" of the entity system and coordinates everything together. Let's see all of this in details.

Setting up the database URI

The database needs to be set up in a database.json file in the config directory. The recommanded way is setting the URI (which is a sensitive information) in the .env.local file and calling it in the database.json file as en environment variable, like this:

Entities

An Entity is a PHP Class with properties and setter and getter methods (as well as custom methods if needed) that abstracts MySql data as PHP objects and makes it easy to manipulate. If you are familiar with Doctrine Entities you will easily recognize the patterns here, but there are some subtle differences. For example, the associated information used for the database is not set as annotations but as a JSON file with all the needed information (more below in the Entities Config section). Here is an example of a part of an entity :

Repository

The repository is where the entity or entities are retrieved and hydrated, it consists of a class extending an abstract Repository class. The most important part here is having to pass the entity name as a string.

Example :

Entities config

The entities need JSON configuration files that need to be placed in the /config/entities/ folder with the same name as the entity. Those files need to contain :

Example :

Entity Manager

The Entity Manager serves as the coordinator, it gets, parses and passes the entities data, connects to the database through PDO, passes the queries, is used to add, modify or remove entities.

most important methods

EntityManager has several important methods to know :

Security

Security is an important part of any web application and framework, and this framework comes with several features to enhance this.

Firewall

The firewall is set up in /config/security.json, the important part inside this file is the firewalls part, which has three parameters :

Example :

Other security considerations

Forms

The Form class is an in-built system that makes it easy to rapidly do secure forms that can be associated or not with an entity (and automatically adds the processed input data into it). In this framework, forms are very customizable with lots of option that can be entered in an array. Here are some examples of forms :

Contact form :

Register form :

Blog post creator/editor form :

As we can see this system is very customizable and robust. We can add input types and pass some data, a name and options in an array, for each input field.

To instantiate a form there are several ways :

Here is an example using the third method :

Form class options

The form class can have several options passed to it in the $options array :

Inputs / Form creation methods

Input options

inputs need to be named. If they are to be associated with an entity property, this name needs to be the same as the associated property.

Each input has their specific available options, like placeholders, default values etc, here are some of them.

Rendering a form

To render a form, it needs to be passed with the method renderForm(), this can be passed to twig or even as an AJAX call

this can then be rendered easily :

The form can be used as AJAX data, by using the form.data (which gives raw data about the form and the inputs) instead of form.render (which renders the form, with the html already generated)

Email

Configurating the emailing

If used, the email settings need to be configurated inside /config/email.json

Defaults

phpmailer

Example :

Usable methods

Commands

The framework includes an extensible command system, with some base commands that can be used to easily generate new entities or controllers for example. To use a command you need to call the main managing script and precise the command as well as the necessary options or arguments like this :

Base commands

Here are some commands that are provided with the framework :

Configure and create commands

the command configuration is done inside /config/commands.json, active commands need to be added in this file with a name and the namespace of the command, like this :

Commands need to be extended from the Command class. each command needs to be configured inside the configure() method, this is where the name of the command, the alias, the options, the arguments and the description are added. The actual command execution code has to be put inside an execute() method, here is an example :

Helper classes and methods

Several classes and methods can be used to help with different tasks, they can mainly be found in the Core\utils namespace :

Paginator

There are two methods :

StringUtils

They are static funtions that can help with strings :

JsonParser

ClassUtils

License

MIT


All versions of sirius with dependencies

PHP Build Version
Package Version
Requires php Version >=7.4
vlucas/phpdotenv Version ^5.3
twig/twig Version ^3.0
ext-pdo Version ^7.3
ext-json Version *
phpmailer/phpmailer Version ^6.3
ramsey/uuid Version ^4.1
ext-fileinfo Version *
composer/composer Version 2.1.x-dev
ext-dom Version *
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 tavrin/sirius contains the following files

Loading the files please wait ....