PHP Classes
elePHPant
Icontem

spiral: Modular Web application development framework

Recommend this page to a friend!
  Info   View files Documentation   View files View files (207)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2017-04-11 (1 month ago) RSS 2.0 feedNot yet rated by the usersTotal: 54 This week: 1All time: 8,837 This week: 640Up
Version License PHP version Categories
spiral 1.0.0The PHP License7Libraries, PHP 7
Description Author

This package is a modular Web application development framework.

It provides base classes for controllers, boot loaders, record entity, etc..

Name: Wolfy-J <contact>
Classes: 1 package by
Country: Belarus Belarus
Age: 26
All time rank: 407812 in Belarus Belarus
Week rank: 519 Up2 in Belarus Belarus Up

Details

Spiral, PSR7/PHP7 Framework

Latest Stable Version Total Downloads License Build Status Scrutinizer Code Quality Coverage Status

<img src="https://raw.githubusercontent.com/spiral/guide/master/resources/logo.png" height="170px" alt="Spiral Framework" align="left"/>

The Spiral framework provides open and modular Rapid Application Development (RAD) environment, database tools, code re-usability, extremely friendly IoC, IDE integration, PSR-7, simple syntax and customizable scaffolding mechanisms.

<b>Skeleton App</b> | Guide | Twitter | Modules | CHANGELOG | Contributing | Forum

<br/><br/>

Examples:

class HomeController extends Controller
{
    /
     * IoC Container can automatically deside what database/cache/storage
     * instance to provide for every action parameter based on it's 
     * name or type.
     *
     * @param Database   $database
     * @param Database   $logs     Can be physical or virtual database
     * @param HttpConfig $config   
     * @return string
     */
    public function indexAction(Database $database, Database $logs, HttpConfig $config): string 
    {
        dump($config->basePath());
    
        $logs->table('log')->insertOne(['message' => 'Yo!']);
    
        return $this->views->render('welcome', [
            'users' => $database->table('users')->select()->where(['name' => 'John'])->all()
        ]);
    }
}

Bootloaders, Factory Methods:

class MyBootloader extends Bootloader
{
    const BINDINGS = [
        ParserInterface::class => DefaultParser::class,
        'someService'          => SomeService::class
    ];
    
    const SINGLETONS = [
        ReaderInterface::class => [self::class, 'makeReader'],
    ];
    
    protected function makeReader(ParserInterface $parser, Database $database): Reader
    {
        return new Reader($parser, $database->table('some'));
    }
}

Declarative/lazy singletons and services:

class SomeService implements SingletonInterface
{
    private $reader;
    
    public function __construct(ReaderInterface $reader)
    {
        $this->reader = $reader;
    }

    public function readValue(string $value): string
    {
        return $this->reader->read($value);
    }
}

JSON responses, method injections, IoC scopes, container shortcuts, IDE helpers:

public function indexAction(ServerRequestInterface $request, SomeService $service): array
{
    dump($service->readValue('abc'));
    
    //Shortcuts
    dump($this->someService === $service);
    
    return [
        'status' => 200,
        'uri'    => (string)$request->getUri()
    ];
}

Short Bindings

Spiral application(s) can be used as middleware/endpoint inside other PSR7 frameworks:

use Zend\Diactoros\Server;
use Zend\Expressive\Application;
use Zend\Stratigility\MiddlewarePipe;

$app = new Application();
$app->any('/spiral', SpiralApp::init(...)->http);

ORM with scaffolding/migrations for MySQL, PostgresSQL, SQLite, SQLServer:

class Post extends RecordEntity
{
    use TimestampsTrait;

    //Database partitions, isolation and aliasing
    const DATABASE = 'blog';

    const SCHEMA = [
        'id'     => 'bigPrimary',
        'title'  => 'string(64)',
        'status' => 'enum(published,draft)',
        'body'   => 'text',
        
        //Simple relation definitions
        'comments' => [self::HAS_MANY => Comment::class],
        
        //Not very simple relation definitions
        'collaborators' => [
            self::MANY_TO_MANY  => User::class,
            self::PIVOT_TABLE   => 'post_collaborators_map',
            self::PIVOT_COLUMNS => [
                'time_assigned' => 'datetime',
                'type'          => 'string, nullable',
            ],
            User::INVERSE       => 'collaborated_posts'
        ],
        
        //Pre-compiled relations
        'author'   => [
            self::BELONGS_TO   => AuthorInterface::class,
            self::LATE_BINDING => true
        ],
               
        //Hybrid databases
        'metadata' => [
            Document::ONE => Mongo\Metadata::class
        ]
    ];
}

$posts = $postSource->find()->distinct()
    ->with('comments', ['where' => ['{@}.approved' => true]]) //Automatic joins
    ->with('author')->where('author_name', 'LIKE', $authorName) //Fluent
    ->load('comments.author') //Cascade eager-loading (joins or external query)
    ->paginate(10) //Quick pagination using active request
    ->getIterator();

foreach($posts as $post) {
    echo $post->author->getName();
}

$post = new Post();
$post->publish_at = 'tomorrow 8am';
$post->author = new User(['name' => 'Antony']);

$post->tags->link(new Tag(['name' => 'tag A']));
$post->tags->link($tags->findOne(['name' => 'tag B']));

$transaction = new Transaction();
$transaction->store($post);
$transaction->run();

dump($post); //You can also use AR or UoW approach

And much more: <b>Skeleton App</b> | Guide

Tests

composer install
vendor/bin/phpunit
  Files folder image Files  
File Role Description
Files folder imagesource (2 files, 2 directories)
Files folder imagetests (5 files, 17 directories)
Accessible without login Plain text file .coveralls.yml Data Auxiliary data
Accessible without login Plain text file .travis.yml Data Auxiliary data
Accessible without login Plain text file CHANGELOG.md Data Auxiliary data
Accessible without login Plain text file composer.json Data Auxiliary data
Accessible without login Plain text file LICENSE Lic. License text
Accessible without login Plain text file phpunit.xml Data Auxiliary data
Accessible without login Plain text file README.md Doc. Documentation

  Files folder image Files  /  source  
File Role Description
Files folder imageSpiral (13 directories)
Files folder imageviews (1 directory)
  Plain text file functions.php Class Class source
  Accessible without login Plain text file server.php Aux. Auxiliary script

  Files folder image Files  /  source  /  Spiral  
File Role Description
Files folder imageCommands (1 file)
Files folder imageConsole (6 files)
Files folder imageCore (15 files)
Files folder imageDebug (4 files)
Files folder imageEncrypter (3 files)
Files folder imageHttp (8 files)
Files folder imageModules (6 files)
Files folder imagePagination (1 file)
Files folder imageSession (5 files)
Files folder imageSupport (2 files)
Files folder imageTranslator (6 files)
Files folder imageValidation (4 files)
Files folder imageViews (10 files)

  Files folder image Files  /  source  /  Spiral  /  Commands  
File Role Description
  Plain text file ServerCommand.php Class Class source

  Files folder image Files  /  source  /  Spiral  /  Console  
File Role Description
  Plain text file Command.php Class Class source
  Plain text file CommandLocator.php Class Class source
  Plain text file CommandOutput.php Class Class source
  Plain text file ConsoleDispatcher.php Class Class source
  Plain text file LocatorInterface.php Class Class source
  Plain text file NullLocator.php Class Class source

  Files folder image Files  /  source  /  Spiral  /  Core  
File Role Description
  Plain text file AbstractCore.php Class Class source
  Plain text file BootloadManager.php Class Class source
  Plain text file ConfigFactory.php Class Class source
  Plain text file ContainerInterface.php Class Class source
  Plain text file Controller.php Class Class source
  Plain text file Core.php Class Class source
  Plain text file DirectoriesInterface.php Class Class source
  Plain text file DispatcherInterface.php Class Class source
  Plain text file DotenvEnvironment.php Class Class source
  Plain text file Environment.php Class Class source
  Plain text file EnvironmentInterface.php Class Class source
  Plain text file Loader.php Class Class source
  Plain text file Memory.php Class Class source
  Plain text file ScoperInterface.php Class Class source
  Plain text file Service.php Class Class source

  Files folder image Files  /  source  /  Spiral  /  Debug  
File Role Description
  Plain text file LogManager.php Class Class source
  Plain text file QuickSnapshot.php Class Class source
  Plain text file Snapshot.php Class Class source
  Plain text file SnapshotInterface.php Class Class source

  Files folder image Files  /  source  /  Spiral  /  Encrypter  
File Role Description
  Plain text file Encrypter.php Class Class source
  Plain text file EncrypterInterface.php Class Class source
  Plain text file EncrypterManager.php Class Class source

  Files folder image Files  /  source  /  Spiral  /  Http  
File Role Description
  Plain text file ErrorWriter.php Class Class source
  Plain text file HttpCore.php Class Class source
  Plain text file HttpDispatcher.php Class Class source
  Plain text file HttpInterface.php Class Class source
  Plain text file MiddlewareInterface.php Class Class source
  Plain text file MiddlewarePipeline.php Class Class source
  Plain text file RESTfulCore.php Class Class source
  Plain text file Uri.php Class Class source

  Files folder image Files  /  source  /  Spiral  /  Modules  
File Role Description
  Plain text file ConfigInjector.php Class Class source
  Plain text file ModuleInterface.php Class Class source
  Plain text file Publisher.php Class Class source
  Plain text file PublisherInterface.php Class Class source
  Plain text file Registrator.php Class Class source
  Plain text file RegistratorInterface.php Class Class source

  Files folder image Files  /  source  /  Spiral  /  Pagination  
File Role Description
  Plain text file PaginationFactory.php Class Class source

  Files folder image Files  /  source  /  Spiral  /  Session  
File Role Description
  Plain text file SectionInterface.php Class Class source
  Plain text file Session.php Class Class source
  Plain text file SessionFactory.php Class Class source
  Plain text file SessionInterface.php Class Class source
  Plain text file SessionSection.php Class Class source

  Files folder image Files  /  source  /  Spiral  /  Support  
File Role Description
  Plain text file ExceptionHelper.php Class Class source
  Plain text file Strings.php Class Class source

  Files folder image Files  /  source  /  Spiral  /  Translator  
File Role Description
  Plain text file Catalogue.php Class Class source
  Plain text file Indexer.php Class Class source
  Plain text file LocatorInterface.php Class Class source
  Plain text file TranslationLocator.php Class Class source
  Plain text file Translator.php Class Class source
  Plain text file TranslatorInterface.php Class Class source

  Files folder image Files  /  source  /  Spiral  /  Validation  
File Role Description
  Plain text file CheckerInterface.php Class Class source
  Plain text file ValidatesEntity.php Class Class source
  Plain text file Validator.php Class Class source
  Plain text file ValidatorInterface.php Class Class source

  Files folder image Files  /  source  /  Spiral  /  Views  
File Role Description
  Plain text file DynamicEnvironment.php Class Class source
  Plain text file EngineInterface.php Class Class source
  Plain text file EnvironmentInterface.php Class Class source
  Plain text file LoaderInterface.php Class Class source
  Plain text file ProcessorInterface.php Class Class source
  Plain text file ViewInterface.php Class Class source
  Plain text file ViewLoader.php Class Class source
  Plain text file ViewManager.php Class Class source
  Plain text file ViewsInterface.php Class Class source
  Plain text file ViewSource.php Class Class source

  Files folder image Files  /  source  /  views  
File Role Description
Files folder imagehttp (4 files)

  Files folder image Files  /  source  /  views  /  http  
File Role Description
  Accessible without login Plain text file 400.dark.php Aux. Auxiliary script
  Accessible without login Plain text file 403.dark.php Aux. Auxiliary script
  Accessible without login Plain text file 404.dark.php Example Example script
  Accessible without login Plain text file 500.dark.php Aux. Auxiliary script

  Files folder image Files  /  tests  
File Role Description
Files folder image-app- (1 file, 5 directories)
Files folder imageCommands (6 directories)
Files folder imageConsole (4 files)
Files folder imageControllers (1 file)
Files folder imageCore (14 files)
Files folder imageDatabase (1 file)
Files folder imageDebug (2 files)
Files folder imageEncrypter (3 files)
Files folder imageHttp (23 files)
Files folder imageModels (2 files)
Files folder imageModules (2 files)
Files folder imagePagination (1 file)
Files folder imageSession (4 files)
Files folder imageSupport (2 files)
Files folder imageTranslator (6 files)
Files folder imageValidation (2 files)
Files folder imageViews (7 files)
  Plain text file BaseTest.php Class Class source
  Accessible without login Plain text file bootstrap.php Aux. Auxiliary script
  Accessible without login Plain text file php-travis.ini Data Auxiliary data
  Accessible without login Plain text file README.md Doc. Documentation
  Plain text file TestApplication.php Class Class source

  Files folder image Files  /  tests  /  -app-  
File Role Description
Files folder imagealternative (3 files)
Files folder imageclasses (4 files)
Files folder imageconfig (15 files)
Files folder imagefixtures (1 file)
Files folder imageviews (10 files)
  Accessible without login Plain text file .env Data Auxiliary data

  Files folder image Files  /  tests  /  -app-  /  alternative  
File Role Description
  Accessible without login Plain text file home.dark.php Aux. Auxiliary script
  Accessible without login Plain text file isolated.twig Data Auxiliary data
  Accessible without login Plain text file native.php Aux. Auxiliary script

  Files folder image Files  /  tests  /  -app-  /  classes  
File Role Description
  Plain text file EmptyModule.php Class Class source
  Plain text file InvalidModule.php Class Class source
  Plain text file ProfilerModule.php Class Class source
  Plain text file TestModule.php Class Class source

  Files folder image Files  /  tests  /  -app-  /  config  
File Role Description
  Accessible without login Plain text file app.php Aux. Auxiliary script
  Accessible without login Plain text file broken.php Aux. Auxiliary script
  Accessible without login Plain text file console.php Aux. Auxiliary script
  Plain text file databases.php Class Class source
  Accessible without login Plain text file encrypter.php Aux. Auxiliary script
  Plain text file http.php Class Class source
  Accessible without login Plain text file migrations.php Aux. Auxiliary script
  Accessible without login Plain text file mongo.php Aux. Auxiliary script
  Plain text file monolog.php Class Class source
  Plain text file session.php Class Class source
  Accessible without login Plain text file snapshots.php Aux. Auxiliary script
  Accessible without login Plain text file tokenizer.php Aux. Auxiliary script
  Plain text file translator.php Class Class source
  Plain text file validation.php Class Class source
  Plain text file views.php Class Class source

  Files folder image Files  /  tests  /  -app-  /  fixtures  
File Role Description
  Accessible without login Plain text file hello.world Data Auxiliary data

  Files folder image Files  /  tests  /  -app-  /  views  
File Role Description
  Accessible without login Plain text file hello.twig Data Auxiliary data
  Accessible without login Plain text file home.dark.php Aux. Auxiliary script
  Accessible without login Plain text file invalid.twig Data Auxiliary data
  Accessible without login Plain text file isolated-x.twig Data Auxiliary data
  Accessible without login Plain text file isolated-y.twig Data Auxiliary data
  Accessible without login Plain text file isolated.twig Data Auxiliary data
  Accessible without login Plain text file native.php Aux. Auxiliary script
  Accessible without login Plain text file run.dark.php Aux. Auxiliary script
  Accessible without login Plain text file sample.twig Data Auxiliary data
  Accessible without login Plain text file valued.twig Data Auxiliary data

  Files folder image Files  /  tests  /  Commands  
File Role Description
Files folder imageDatabase (2 files)
Files folder imageMigrations (1 file)
Files folder imageModules (2 files)
Files folder imageODM (1 file)
Files folder imageORM (1 file)
Files folder imageSpiral (3 files)

  Files folder image Files  /  tests  /  Commands  /  Database  
File Role Description
  Plain text file DescribeCommandTest.php Class Class source
  Plain text file ListCommandTest.php Class Class source

  Files folder image Files  /  tests  /  Commands  /  Migrations  
File Role Description
  Plain text file SchemaBasedTest.php Class Class source

  Files folder image Files  /  tests  /  Commands  /  Modules  
File Role Description
  Plain text file PublishCommandTest.php Class Class source
  Plain text file RegisterCommandTest.php Class Class source

  Files folder image Files  /  tests  /  Commands  /  ODM  
File Role Description
  Plain text file SchemaCommandTest.php Class Class source

  Files folder image Files  /  tests  /  Commands  /  ORM  
File Role Description
  Plain text file SchemaCommandTest.php Class Class source

  Files folder image Files  /  tests  /  Commands  /  Spiral  
File Role Description
  Plain text file BootloadsCommandTest.php Class Class source
  Plain text file CleanCommandTest.php Class Class source
  Plain text file ConfigureCommandTest.php Class Class source

  Files folder image Files  /  tests  /  Console  
File Role Description
  Plain text file ConfigTest.php Class Class source
  Plain text file DispatcherTest.php Class Class source
  Plain text file NullLocatorTest.php Class Class source
  Plain text file VerbosityTest.php Class Class source

  Files folder image Files  /  tests  /  Controllers  
File Role Description
  Plain text file AuthorizesController.php Class Class source

  Files folder image Files  /  tests  /  Core  
File Role Description
  Plain text file AuthorizesTraitTest.php Class Class source
  Plain text file BootloadersTest.php Class Class source
  Plain text file ConfigsTest.php Class Class source
  Plain text file ControllersTest.php Class Class source
  Plain text file CoreTest.php Class Class source
  Plain text file DirectoriesTest.php Class Class source
  Plain text file EnvironmentTest.php Class Class source
  Plain text file ErrorHandlingTest.php Class Class source
  Plain text file LoaderTest.php Class Class source
  Plain text file MemoryTest.php Class Class source
  Plain text file RouteScopeTest.php Class Class source
  Plain text file ScopingTest.php Class Class source
  Plain text file ServicesTest.php Class Class source
  Plain text file TimezonesTest.php Class Class source

  Files folder image Files  /  tests  /  Database  
File Role Description
  Plain text file SessionsTest.php Class Class source

  Files folder image Files  /  tests  /  Debug  
File Role Description
  Plain text file QuickSnapshotTest.php Class Class source
  Plain text file SnapshotTest.php Class Class source

  Files folder image Files  /  tests  /  Encrypter  
File Role Description
  Plain text file ComponentTest.php Class Class source
  Plain text file ConfigTest.php Class Class source
  Plain text file EncrypterTest.php Class Class source

  Files folder image Files  /  tests  /  Http  
File Role Description
  Plain text file BasePathTest.php Class Class source
  Plain text file ClientExceptionsTest.php Class Class source
  Plain text file ControllerRouteTest.php Class Class source
  Plain text file CookieManagerTest.php Class Class source
  Plain text file CookieTest.php Class Class source
  Plain text file CsrfMiddlewareTest.php Class Class source
  Plain text file FilesBagTest.php Class Class source
  Plain text file HeaderBagTest.php Class Class source
  Plain text file HttpCoreTest.php Class Class source
  Plain text file HttpDispatcherTest.php Class Class source
  Plain text file HttpTest.php Class Class source
  Plain text file InputManagerTest.php Class Class source
  Plain text file JsonParserTest.php Class Class source
  Plain text file MatchesTest.php Class Class source
  Plain text file PipelineTest.php Class Class source
  Plain text file ResponseWrapperTest.php Class Class source
  Plain text file RESTfulCoreTest.php Class Class source
  Plain text file RouterTest.php Class Class source
  Plain text file RouteTest.php Class Class source
  Plain text file ServerBagTest.php Class Class source
  Plain text file SpiralMiddlewareTest.php Class Class source
  Plain text file UriGenerationTest.php Class Class source
  Plain text file UriTest.php Class Class source

  Files folder image Files  /  tests  /  Models  
File Role Description
  Plain text file SqlTimestampsTest.php Class Class source
  Plain text file UTCTimestampsTest.php Class Class source

  Files folder image Files  /  tests  /  Modules  
File Role Description
  Plain text file ConfigInjectorTest.php Class Class source
  Plain text file PublisherTest.php Class Class source

  Files folder image Files  /  tests  /  Pagination  
File Role Description
  Plain text file PaginationFactoryTest.php Class Class source

  Files folder image Files  /  tests  /  Session  
File Role Description
  Plain text file FactoryTest.php Class Class source
  Plain text file NullHandlerTest.php Class Class source
  Plain text file SessionMiddlewareTest.php Class Class source
  Plain text file SignaturesTest.php Class Class source

  Files folder image Files  /  tests  /  Support  
File Role Description
  Plain text file ExceptionHelperTest.php Class Class source
  Plain text file StringsTest.php Class Class source

  Files folder image Files  /  tests  /  Translator  
File Role Description
  Plain text file CatalogueTest.php Class Class source
  Plain text file ConfigTest.php Class Class source
  Plain text file LocatorTest.php Class Class source
  Plain text file PHPLoaderTest.php Class Class source
  Plain text file TraitTest.php Class Class source
  Plain text file TranslatorTest.php Class Class source

  Files folder image Files  /  tests  /  Validation  
File Role Description
  Plain text file ValidatesEntityTest.php Class Class source
  Plain text file ValidatorTest.php Class Class source

  Files folder image Files  /  tests  /  Views  
File Role Description
  Plain text file EnvironmentTest.php Class Class source
  Plain text file EvaluatorTest.php Class Class source
  Plain text file LoaderTest.php Class Class source
  Plain text file ManagerTest.php Class Class source
  Plain text file NativeTest.php Class Class source
  Plain text file StemplerTest.php Class Class source
  Plain text file TwigTest.php Class Class source

 Version Control Unique User Downloads Download Rankings  
 100%
Total:54
This week:1
All time:8,837
This week:640Up