Download the PHP package tahona/spark-mvc without Composer

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

README

What is this repository for?

Very fast PHP framework with autoloading and annotations. All configuration is handled by annotations and beans.

How it works

Framework automatically load beans from app/src path it just need to be annotated with one annotation of: @Component, @Service, @Configuration or @Repository.

Bean injection can be achieved with @Inject annotation.

Initialization is done on the first request. The second request execute Controllers action, that has already injected beans in it.

Request execution time is very small because it's time of user code execution only.

Thanks to this, for real production code we got 20ms-40ms per request for dynamic data.

Quick Start

For quick start donwload example project: https://github.com/primosz67/spark-mvc-example

Index php - explained

app/public/index.php

Note: If you will use doctrine db framework add here line - "AnnotationRegistry::registerLoader('class_exists');"

Framework setup:

Configuration

app/src/MyAppConfig.php

Controller

1. Standard Controller with annotation controller

app/src/MyAppController.php

Go to localhost/get or localhost/index;

2. Rest Controller

Note: All methods in RestController will resolve to JSON.

SomeResultDto - will resolve to json.

3. Old method of creating Controller

app/src/MyAppController.php

Go to localhost/get or localhost/index;

2. Define bean for autoload.

Injection

1. Define bean for autoload.

Note: for enabled apcu @EnableApcuBeanCache("reset") to autoload injection, call http://website?reset

2. Define other beans and inject out bean.
3.Inject in controller
4.Inject in action method of controller

View

apc/view/{controller package}/{controllerName (without "Controller")}/{action}.tpl

  1. For app/src/MyAppController@showNewViewAction we get: apc/view/myapp/showNewView.tpl
  2. For app/src/some/serious/package/controller/MyAppController@showNewViewAction we get: apc/view/some/serious/package/myapp/showNewView.tpl

Keywords action and controller are deleted by default.

Smarty built-in path plugins

Function path can be used in tpl file (example: index.tpl)

Command will resolve to : www.example.com/user/register

Command will resolve to : www.example.com/user/register

Command will resolve to : www.example.com/blogpost/remove/4

Apcu Bean Cache

if @EnableApcuBeanCache annotation is added with @Configuration the only way to reset beans and init them once more is by requestin localhost:80?reset (GET parameter "reset").

Mailer

@Annotations

The heart of Spark Framework.

Application Parameters

$this->config

Base parameters: app.path - pierwsza ścieżka do katalogu /app src.path - ścieżka do katalogu /app/src app.paths - ścieżka albo ścieżki do katalogu /app w różnych kontekstach

to fetch parameters:

update or set Params

Custom module loading

If you create common module to use in other project remember to create beans by @Bean annotation. It will be easier to add new module in one go.

In some your app configuration add others OtherModuleConfig.

All @Bean annotation in OtherModuleConfig will be created and inject to your classes.

Multiple DataBase connection (example)

Handle multiple connections. To create Doctrine's EntityManager you can use simple EntityManagerFactory.

Note: for using CrudDao with other enityManager than basic use @OverrideInject annotation

Internalization

Bean definition

Where "pl","cz","en" are cookie value with key "lang";

Results: Thank You John and Trevor

@Path

Annotation Defonition

Fetch path paramether in Controller class;

MULTI fetch by component

Example is for dynamic menu module that will popup when new project or classes are added.

Interceptors

Command behaviour for PHP cli

First, create class Command implementation

in console execute:

Output:

Built-in cache service

Great thing for caching DB request or loading files data. Annotation can be used with different cache. Even custom cache bean that implement spark/cache/Cache

How To

In Bean class add @Cache annotation.

Profiles

In this case SomeDevelopmentConfig won't be added to container and bean declared in it (@Bean) as well.

Error handling - example

where error handler with order equal 0 , will be first to invoke. If you return Viewmodel the handling will stop and the view will be return as response.

Event Bus

Event definition :

Subscription

AnnotationHandler

Add Your own annotation

Installation - Composer - Speed up

Performance - Some numbers

Tested Case: Real project with small database. AB(Apache benchmark) requests 10000 and 1000 parallel connections.

Mode Request time (per request)
Smarty compile ~130ms
Smarty ~45ms
Smarty + @Cache (Redis) ~25ms

Installation - Composer


All versions of spark-mvc with dependencies

PHP Build Version
Package Version
Requires php Version >=7.1
doctrine/common Version >=v2.5.3
doctrine/annotations Version >=v1.4.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 tahona/spark-mvc contains the following files

Loading the files please wait ....