phoneburner / pinch
The Pinch API Framework Monorepo
Requires
- php: ^8.4
- ext-amqp: *
- ext-bcmath: *
- ext-ctype: *
- ext-curl: *
- ext-exif: *
- ext-gmp: *
- ext-iconv: *
- ext-igbinary: *
- ext-intl: *
- ext-json: *
- ext-mbstring: *
- ext-pdo: *
- ext-pdo_mysql: *
- ext-random: *
- ext-redis: *
- ext-sodium: *
- ext-zend-opcache: *
- ext-zip: *
- ext-zlib: *
- alek13/slack: ^2.3
- aws/aws-sdk-php: ^3.351.3
- crell/api-problem: ^3.7
- crell/attributeutils: ^1.3
- crell/serde: ^1.5.0
- doctrine/dbal: ^4.3.0
- doctrine/migrations: ^3.9.1
- doctrine/orm: ^3.5.0
- dragonmantank/cron-expression: ^3.4
- eventsauce/eventsauce: ^3.7.1
- eventsauce/message-repository-for-doctrine: ^1.2.1
- filp/whoops: ^2.18.3
- guzzlehttp/guzzle: ^7.9.3
- guzzlehttp/psr7: ^2.7.1
- laminas/laminas-diactoros: ^3.6.0
- laminas/laminas-httphandlerrunner: ^2.12
- league/flysystem: ^3.30.0
- league/flysystem-aws-s3-v3: ^3.29
- monolog/monolog: ^3.9.0
- nesbot/carbon: ^2.73.0 || ^3.10.1
- nikic/fast-route: ^1.3
- phoneburner/api-handler: ^1.0.1
- phoneburner/composer-replacements: ^1.0.0
- phoneburner/http-tortilla: ^2.0.0
- phoneburner/link-tortilla: ^1.0.0
- phpstan/extension-installer: ^1.4.3
- phpstan/phpstan: ^2.1.19
- phpstan/phpstan-deprecation-rules: ^2.0.3
- phpstan/phpstan-doctrine: ^2.0.4
- phpstan/phpstan-phpunit: ^2.0.7
- psr/cache: ^3.0.0
- psr/clock: ^1.0.0
- psr/container: ^1.1.2 || ^2.0.2
- psr/event-dispatcher: ^1.0.0
- psr/http-client: ^1.0.3
- psr/http-factory: ^1.1.0
- psr/http-message: ^2.0.0
- psr/http-server-handler: ^1.0.2
- psr/http-server-middleware: ^1.0.2
- psr/link: ^2.0.1
- psr/log: ^3.0.2
- psr/simple-cache: ^3.0.0
- psy/psysh: ^0.12.9
- ramsey/uuid: ^4.9.0
- ramsey/uuid-doctrine: ^2.1
- spaze/phpstan-disallowed-calls: ^4.6.0
- symfony/amazon-sqs-messenger: ^7.3
- symfony/amqp-messenger: ^7.3.0
- symfony/cache: ^7.3.1
- symfony/console: ^7.3
- symfony/doctrine-messenger: ^7.3
- symfony/event-dispatcher: ^7.3.0
- symfony/http-client: ^7.3.1
- symfony/lock: ^7.3.0
- symfony/mailer: ^7.3.1
- symfony/messenger: ^7.3.1
- symfony/mime: ^7.3.0
- symfony/process: ^7.3
- symfony/redis-messenger: ^7.3.0
- symfony/scheduler: ^7.3.0
- symfony/sendgrid-mailer: ^7.3.0
- symfony/service-contracts: ^3.6
- symfony/var-exporter: ^7.3.0
Requires (Dev)
- behat/behat: ^3.23.0
- brianium/paratest: ^7.11
- eventsauce/test-utilities: dev-main
- league/openapi-psr7-validator: ^0.22.0
- phoneburner/coding-standard: ^1.0.0
- php-parallel-lint/php-parallel-lint: ^1.4
- phpunit/phpunit: ^12.2.7
- rector/rector: ^2.1.2
- roave/security-advisories: dev-latest
- symfony/var-dumper: ^7.3.1
- symplify/monorepo-builder: ^11.2
Provides
Replaces
- phoneburner/pinch-component: v0.0.18
- phoneburner/pinch-core: v0.0.18
- phoneburner/pinch-framework: v0.0.18
- phoneburner/pinch-phpstan: v0.0.18
- phoneburner/pinch-template: v0.0.18
README
Pinch Framework
Feels like home, just without the salty tears of frustration
The Pinch Framework is a "batteries-included," very-highly-opinionated PHP framework, derived from the original Salt framework/application used by PhoneBurner. While modeled on other modern "general purpose" frameworks like Symfony and Laravel, the Pinch Framework is designed and optimized as an API backend.
Ideally, it adapts the best core features of Salt without dragging along unnecessary complexity, technical debt, and the (many) design decisions we regret. The goal is to provide users with a robust framework with minimum cognitive overhead from the original Salt framework, avoiding the pitfalls of bringing in a full-fledged third-party framework and trying to adapt that to our needs.
Guiding Principles
- Compatiblity with the PSRs should be the general rule, but sensible deviations are allowed, especially in the name of type safety.
- Where practical, third-party library code should be wrapped in a way that lets us expose our own interface. This allows us to swap out the underlying library without changing application code.
- Separation of "framework" and "application" concerns
- Take the best parts of Salt, leave the rest, and add new features wrapping the best of modern PHP
- Configuration driven, with environment variables as the primary source of overrides
Notable Differences from Salt
- The time zone configuration for PHP and the database is set to UTC by default.
- Configuration is defined by the environment, and not by the path value of a request.
- Overriding configuration values is done via environment variables, not by adding local configuration files.
- Database migrations are handled by the Doctrine Migrations library, as opposed to Phinx.
- PHPUnit 12 is used for testing, this is a significant upgrade from the previous version. Notably, unit tests are defined with attributes and data providers must be defined as static functions.
- When cast to a string,
\Phoneburner\Pinch\Component\PhoneNumber\DomesticPhoneNumber
is formatted as an E.164 phone number ("+13145551234"), instead a ten-digit number ("3145551234").
Backwards Capability Guarantees
Classes and interfaces with the #[PhoneBurner\Pinch\Attribute\Usage\Contract]
attribute
are considered part of the public API of the framework and should not be changed without
a major version bump. These "contracts" can be freely used in application code.
Conversely, classes and interfaces with the #[PhoneBurner\Pinch\Attribute\Usage\Internal]
attribute are very tightly coupled to third-party vendor and/or framework logic,
and should not be used in application code.
Included Functionality
- PSR-7/PSR-15 Request & Response Handling
- PSR-11 Dependency Injection Container
- PSR-3 Logging with Monolog
- PSR-14 Event Dispatching based on Symfony EventDispatcher
- Local/Remote Filesystem Operations with Flysystem
- Development Environment Error Handling with Whoops
- Console Commands with Symfony Console
- Interactive PsySH Shell with Application Runtime
- Doctrine ORM & Migrations
- Redis for Remote Caching with PSR-6/PSR-16 Support
- RabbitMQ for Message Queues and Job Processing
- Task Scheduling with Cron Expression Parsing with Symfony Scheduler
- SMTP/API Email Sending with Symfony Mailer
Docker
The default Docker image used by this project is based on Docker's official PHP 8.4 FPM image with default with a few additional extensions installed and configuration tweaks. The base image's "php.ini-production" configure is used as the basis for the php.ini file. The values in this file are overridden by the "php-development.ini" or "php-production.ini" files, depending on the environment.
Sodium
The official PHP 8.4 FPM image ships with an older version of libsodium, which does not support the latest functionality added to PHP's Sodium extension. The project image updates 1.0.20, so AEGIS-256 related functions are available.
XDebug
The PHP Docker image used by this project includes the XDebug extension, but it is not enabled in the same way as the other extensions. To load the XDebug extension, "zend_extension=xdebug.so" must be added to an INI file. It is enabled by default in the Docker image as the "php-development.ini" is copied to the PHP INI directory as "settings.ini". Production builds should copy the "php-production.ini" file instead, which does not include the XDebug extension (enabling the JIT instead).