Download the PHP package therion/framework without Composer

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

Framework

How to Use

1.Install

composer require therion/framework

2. Config

You need to add 2 files who return arrays for http:

  1. modules.php which returns the classnames of your moduleFactories
  2. services.php which returns your services you need (ex. MysqlServce, MongoService etc.)

You need one additoinal file which retunrs an array for cli: cli-modules.php which returns the classnames for your cliModuleFactories

3. Load Application in your index.php

$di = Application::registerApp(AppType::HTTP, $loadedModules, $loadedServices);

$di = Application::registerApp(AppType::CLI, $loadedCliModules, $loadedServices);

4. Load your routes

$di->getRouter()->route()->send(); The method send returns your Response from your handlers.

Note if you want an error handling insert this here

5. Handler and Modules

Module factories need to implement ModuleFactoryInterface. This interface requests the registerRoutes function which is needed to register routes :)

Handlers need to implement HandlerInterface this interfaces. This interface requests the execute function where execution code should be inserted.

6. Requests and Response

You can add new Types of Responses and Requests, they only need to implement the RequestInterface or the ResponseInterface of the framework Default response is JsonResponse

7. Load Services

Services will be automatically loaded, if they are registered in the services config.

Note if you need Parameters which are not services, u can use for example the following line: Service::class => ['param1', 2, 'param3']. This is for example needed for your DBService or TemplateEngineService

You also can load your Modules with static construction Parameters.

8. Register module classes

In your ModuleFactory you can add handler or other classes by adding them onto the DI-Container: $this->di->getContainer()->register(ExampleHandler::class)

If you only fill the first parameter of the register function then in code you have to call the load function with this name. (This means the second param is nullable)

You can decorate the classname. You have to call the register function with a second parameter. The first Parameter now is the Label and the second is the exactly className. For example: . You can load now YourClass by loading thie interface:

If there are dependencies to other classes you need to register them before.

9. Register Routes

In your ModuleFactory you can register new routs in your function registerRoutes.

You can add new routes by using the Routes public functions.

registerGetRoute()

registerPostRoute()

registerPutRoute()

registerDeleteRoute()

First param is always a unique routename

Second param is the uri like /example

Third param is the Handler you want to call with this route

The last param is an array of your route parameters:

10. Register callables

You can register callables in your di. For example for static inits of classes, like the ::fromGlobals() method of a request (see 11.)

You can just register them by using the method of the Container.

You can load the entry by using the from the container. Note the method executes the callable method.

11. Register classes with static parameters

You can register classes with static parameters for example defaultUserId or something else.

For this you have to hand over parameters in the register function of the DI-Container:

You can also name your parameter: (Not recomendet, but possible for complex classes...PERFORMANCE!)

The DI matches the params to their right position.

12. Register your own request or response class

You can Register your own request or response class by adding them to the di. There are two ways to add them:

services.php for whole project:

in a module factory:

13. Using middlewares

The Framework supports using middlewares by replacing the default HttpRouter with your own router object. In this class you can add middlewares by routing.

AppType:Cli

The cli part is the same as the http part with some changes. You always have the "cli" in the name of your interfaces: CliHandlerInterface, CliModuleFactoryInterface

DI and other Classes are nearly the same. Only difference in handlers, you will not have a return in your execute method. And you don't have a Request but Arguments which is a wrapper class for your $argv

You can always use the CliFunctions in your CliHandlers, they are injected by default


All versions of framework with dependencies

PHP Build Version
Package Version
Requires php Version >=8.2
phpunit/phpunit Version ^9.6
phpspec/prophecy-phpunit Version ^1.1.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 therion/framework contains the following files

Loading the files please wait ....