Pckg Documentation
Pckg Documentation
  • About
  • Concept
  • Start
  • Deployment
  • Tests
  • Ecosystem
    • Docker images
    • Skeleton
  • Core packages
    • Auth
    • Cache
    • Collection
    • Concept
    • Database
      • Repository
        • Driver
      • Entity
        • Relations
        • Query
      • Record
        • Fields
        • Model
      • Events
      • Extensions
    • Framework
      • Environment
        • Console
        • Development
        • Production
        • Test
      • Application
      • Providers
      • Config
      • Router
      • Request
      • Response
      • Controller
        • Middleware
        • Afterware
      • View
      • Events
      • Exception
    • Generic
      • Dynamic
      • Generic
      • Maestro
    • Htmlbuilder
      • Elements
        • Form
        • Fields
      • Datasources
      • Validators
      • Decorators
    • Locale
    • Mail
      • Drivers
      • Template
      • Mail
    • Manager
      • Asset manager
      • SEO manager
      • Meta manager
      • Upload manager
      • Vue manager
      • Job manager
      • Locale manager
      • Page manager
    • Migrator
      • Migrations
      • Fields
    • Queue
      • Driver
      • Publisher
      • Subscriber
    • Storage
      • Driver
      • Media
    • Translator
  • More packages
    • API
    • HTTP QL
      • Read
      • Write
      • Uploads
    • Task
      • Async
    • Websocket
      • Server
      • Client
  • Frontend
    • Helpers JS
    • Helpers CSS
  • Extras
    • Parser
    • Payment
    • Tenant
Powered by GitBook
On this page
  • Installation
  • Usage

Was this helpful?

  1. Core packages

Concept

PreviousCollectionNextDatabase

Last updated 2 years ago

Was this helpful?

Package implements context (DI container) and resolvers.

Installation

Require Composer package.

$ composer require pckg/context

Usage

A global context holds singletones and registers resolvers which automatically resolve an instance of the requested class or interface.

There are 4 main resolvers used:

  • ContextResolver - resolves instances registered in the Context

  • FrameworkResolver - resolves singletone services such as Router, Request, Config and similar

  • FormResolver - resolves form, initializes fields, fills defaults from the request body, performs validation

  • ReflectResolver - auto-creates requested interfaces or classes

When the app is accessed/run via entrypoint (index.php, dev.php, console.php or bootstrap.php in tests), we first require Composer's autoload.php file.

On second step, we create a new Context by first registering all resolvers and creating a new Context.

The third step is where the global event Dispatcher is created.

Then we create an Environment and Application, initialize the app, run the app and reach the end of the request lifecycle.

require autoload.php -> create Context -> bind Dispatcher -> create Environment -> create Application -> init app -> run app
pckg/concept