orbiter / satellite-app
Easy to use Event & Middleware Mini-Framework, powered by popular projects and PSR's
Installs: 27
Dependents: 0
Suggesters: 0
Security: 0
Stars: 2
Watchers: 2
Forks: 1
Open Issues: 2
Type:project
Requires
- php: >=8.1
- ext-json: *
- cache/filesystem-adapter: ^1.2
- guzzlehttp/guzzle: ^7.5.0
- middlewares/payload: ^3.0.0
- middlewares/request-handler: ^2.0.0
- monolog/monolog: ^3.2.0
- orbiter/annotations-util: ~0.6.2
- orbiter/satellite: ~0.4.0
- orbiter/satellite-config: ~0.2.1
- orbiter/satellite-console: ~0.5.0
- orbiter/satellite-launch: ~0.1.1
- orbiter/satellite-response: ~0.1.3
- orbiter/satellite-route: ~0.3.0
- orbiter/satellite-system: ~0.0.1
- php-di/php-di: ^6.4.0
- psr/cache: ^1.0|^2.0
- psr/container: ^1.0|^2.0
- psr/event-dispatcher: ^1.0
- psr/http-message: ^1.0
- psr/http-server-handler: ^1.0
- psr/http-server-middleware: ^1.0
- vlucas/phpdotenv: ^5.5.0
Requires (Dev)
- orbiter/satellite-whoops: ~0.1.2
- phpunit/phpunit: ^9.5
- roave/security-advisories: dev-master
This package is auto-updated.
Last update: 2024-10-21 23:58:28 UTC
README
๐
๐ฐ๏ธ
ยท
ยท
๐ฐ๏ธ๐ฐ๏ธ๏ธ ยท
๐ฐ๏ธ๐๐ฐ๏ธ ยท ยท ยท ๐ฐ๏ธ๐
๐ฐ๏ธ๐ฐ๏ธ๏ธ
Easy to use Event & Middleware Framework, powered by popular micro-libraries and based on PSRs.
Supports PHP 8.1+ and composer
TL;DR
Quick-Jump into develop:
composer create-project orbiter/satellite-app ./satellite cd ./satellite # create `.env` file, # add for local-dev: `env=local` touch .env # start PHP Dev Server cd web && php -S localhost:3333 ./index.php display_errors=0 # or point the Apache Root to `/web/` # or point the NGINX entry to `/web/index.php` # or use Docker: `docker-compose up`
Open your browser on: http://localhost:3333
Look into files:
config
folder with app config and wiringassemble.php
composer autoload, gathers configurations and creates the system modules from that configlaunch.php
runsassemble()
and dispatches theSatelliteApp
eventapp
folder with a basic commands and route handler structure
Setup
Install app skeleton and dependencies with composer in folder satellite
:
# with composer installed on machine: composer create-project orbiter/satellite-app satellite # with composer and docker on windows: docker run -it --rm -v %cd%/satellite:/app composer create-project orbiter/satellite-app . docker run -it --rm -v %cd%/satellite:/app composer create-project --stability=dev orbiter/satellite-app:dev-master . # with composer and docker on unix: docker run -it --rm -v `pwd`/satellite:/app composer create-project orbiter/satellite-app . docker run -it --rm -v `pwd`/satellite:/app composer create-project --stability=dev orbiter/satellite-app:dev-master . # go into project folder: cd ./satellite
Run with:
Linux, PHP Dev Server
Setup correct user rights, then start and open http://localhost:3333
chmod +x start.sh ./start.sh
PHP Command-Line
Execute defined commands.
php cli <command> <..attr> <..b>
Docker, docker-compose
Includes configurable PHP Dockerfile with:
- PHP 8.1
- with FPM and a few extensions
- reusing FPM for a clean CLI worker image
- OPCache
- PostgreSQL Client libs (using
pdo
) - NGINX base image for local routing
- customize in Dockerfile
- a more "production" ready image, preconfigured for building in CI with docker-compose--prod.yml
For docker image configs see files in _docker
and _nginx
.
Start containers specified in docker-compose.yml
, then open: http://localhost:3333
docker-compose up # open shell in app container docker-compose exec app sh # run command in temporary worker container docker-compose run --rm worker php cli demo # run extra composer container on windows: docker run -it --rm -v %cd%:/app composer dumpautoload # run extra composer container on unix: docker run -it --rm -v `pwd`:/app composer dumpautoload # run tests with temporary `app` container: docker-compose run -T --rm app sh -c "cd /var/www/html && ./vendor/bin/phpunit --testdox tests" # running tests with a temporary `phpunit` in a prebuild container: docker run -i --rm bemiteu/satellite-app:master sh -c "cd /var/www && wget -O phpunit https://phar.phpunit.de/phpunit-9.phar && chmod +x phpunit && cd html && /var/www/phpunit --testdox tests"
Web-Server
On a web-server the web/index.php
file serves as public entry point.
Apache: point server/vhost root to /web
and use the included .htaccess
NGINX: example files in _nginx.
Config
Use e.g. .env
to add configuration.
Default's config includes:
- env var
env
: if in production or not in production- with value
prod
it is assumed in the App (not the framework) that it is in production - use
$_ENV['env'] === 'prod'
to check for production - for dev-error pages: add var
dev.editor
with one value ofPrettyPageHandler::EDITOR_*
to linkwhoops
"open file" with IDE
- with value
/config/config.php
- main config- configures which other config files are included
- aggregates and caches the config for production usage
/config/dependencies.php
- definitions for PHP-DI/config/events.php
- define app components flow/config/pipeline.php
- setup PSR middlewares and pipeline
PSRs
This app serves as mini-framework, with PSR powered libraries, ready-to-use Annotations and not much more.
It is build upon PSRs and popular, specialized packages implementing them or other great stuff.
- PSR-3 - Logger
- ๐ฆ
monolog/monolog
- more implementations
- ๐ฆ
- PSR-4 - autoload classes and forget
require_once
- handled by composer, more in composer docs.
- PSR-1,12 - Code Style Guides
- except brackets location rule: same-line instead of next-line for opening
{
- except brackets location rule: same-line instead of next-line for opening
- PSR-6 - Cache
- ๐ฆ
cache/filesystem-adapter
- includes
FilesystemCachePoolNormalized
forDoctrine\Common\Annotations\PsrCachedReader
compatibility - more implementations
- ๐ฆ
- PSR-7 - HTTP Message
- ๐ฆ
nyholm\psr7
- request and response data definitions
- used further by
PSR-15
,PSR-17
andPSR-18
- ๐ฆ
- PSR-11 - Container for InterOp
- ๐ฆ
php-di/php-di
- service container for ease and modularity
- dependency injection with
@Annotations
,@var
PHPDoc and Reflection support
- ๐ฆ
- PSR-14 - Event Dispatcher and Listener
- ๐ฆ
orbiter/satellite
- as the core of how things are put together
- ๐ฆ
- PSR-15 - HTTP Handlers
- ๐ฆ
orbiter/satellite-response
- handle route requests with a powerful middleware pipeline
- ๐ฆ
- PSR-16 - Simple Cache
- ๐ฆ
cache/filesystem-adapter
- more implementations
- ๐ฆ
- PSR-17 - HTTP Factories
- ๐ฆ
nyholm\psr7
- context about request
- for request & response initiations
- ๐ฆ
- PSR-18 - HTTP Client
- ๐ฆ
guzzlehttp/guzzle
- send requests to other APIs
- more implementations
- ๐ฆ
๐ฆ = included in
satellite-app
template
Packages
orbiter/satellite
- implements PSR-14 Event Dispatcher and Listener
- with invoker to execute anything, PSR-11 compatible
- optional event-handler based profiling
- see package repository
orbiter/satellite-console
- console execution
- console command annotations
- uses getopt-php
- see package repository
orbiter/satellite-response
- middleware pipe execution
- implements PSR-15 through
equip/dispatch
, PSR-11 compliant - implements PSR-7,17 through
nyholm/psr7
andnyholm/psr7-server
- with simple emitter by
narrowspark/http-emitter
- see package repository
orbiter/satellite-route
- routes by annotations
- uses nikic/fast-route as router
- made for PSR middleware usage, but not limited
- see package repository
orbiter/annotations-util
- annotations by
doctrine/annotations
with cached reflections - get classes, methods and properties which are annotated
- see AnnotationsUtil
- annotations by
orbiter/satellite-whoops
- Whoops error display for CLI and Routes
- only when
$_ENV['env']
notprod
(configurable inassemble.php
)
orbiter/satellite-config
- simple config aggregator with caching
- see package repository
orbiter/satellite-launch
SatelliteApp
event data objects- see package repository
orbiter/satellite-system
- system setup and core wire-up, e.g. from
$config
to a cached PSR container - see package repository
- system setup and core wire-up, e.g. from
A lot of work for APIs is done by PSR-15 HTTP Middleware, find more awesome middlewares.
Download Build
There is no downloadable version - see Setup on how to install with composer.
We use composer as package manager, like in any modern PHP project.
Feel free to reach out for a training request.
License
This project is free software distributed under the MIT License.
Contributors
By committing your code to the code repository you agree to release the code under the MIT License attached to the repository.
Maintained by Michael Becker