PHPackages                             datashaman/phial-project - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. datashaman/phial-project

ActiveLibrary

datashaman/phial-project
========================

Example project for Phial.

00[2 PRs](https://github.com/datashaman/phial-project/pulls)PHP

Since Aug 17Pushed 3y ago1 watchersCompare

[ Source](https://github.com/datashaman/phial-project)[ Packagist](https://packagist.org/packages/datashaman/phial-project)[ RSS](/packages/datashaman-phial-project/feed)WikiDiscussions master Synced 1w ago

READMEChangelogDependenciesVersions (3)Used By (0)

phial-project
=============

[](#phial-project)

Example project for phial.

requirements
------------

[](#requirements)

- AWS cli
- SAM cli
- AWS credentials

instructions
------------

[](#instructions)

- Define version of PHP in *.settings*.
- Add any system and PHP packages in *Dockerfile*. PHP module packages are installed like `yum install -y php74-php-gd`.
- Edit *php.ini* to configure PHP or enable modules.
- Define your *composer* dependencies using the usual methods.
- Adapt bootstrap process in *bootstrap.php* to suit your needs.
- Set your function *handler* in *template.yaml* to be anything invokable.

handlers
--------

[](#handlers)

Regular handlers have the following signature:

```
myHandler(array $event, ContextInterface $context);

```

Parameters are optional, you can type-hint anything from the container.

If you are developing an *HTTP API*, use the `RequestHandlerAdapter` which marshals the *request* and *reponse* to and from a *PSR-17* `RequestHandlerInterface`.

workflow
--------

[](#workflow)

```
sam build
sam deploy --guided
sam local start-api
sam local invoke

```

moving parts
------------

[](#moving-parts)

You do not *have* to use a *DI* container, but it does make things easier. Any *PSR-11* implementation will do. The *PHP-DI* invoker which invokes the handler code will handle *DI* or no *DI*, it doesn't care.

To replace the *DI* container with another implementation, build one in [bootstrap.php](bootstrap.php) and pass it into the invoker construction.

### PSR standards supported

[](#psr-standards-supported)

The following *PSR* interfaces are supported; any compatible implementation can be used, just pass parameters into the handler constructor or use your DI container to autowire it up.

Also listed is the implementation used in this project. The implementations are configured in the config folder, and wired up in service providers.

- [PSR-3 Logger Interface](https://www.php-fig.org/psr/psr-3) - [monolog/monolog](https://packagist.org/packages/monolog/monolog)
- [PSR-7 HTTP Message Interface](https://www.php-fig.org/psr/psr-7) - [laminas/laminas-diactoros](https://packagist.org/packages/laminas/laminas-diactoros)
- [PSR-11 Container Interface](https://www.php-fig.org/psr/psr-11) - [php-di/php-di](https://packagist.org/packages/php-di/php-di)
- [PSR-14 Event Dispatcher](https://www.php-fig.org/psr/psr-14) - [circli/event-dispatcher](https://packagist.org/packages/circli/event-dispatcher)
- [PSR-15 Server Request Handlers](https://www.php-fig.org/psr/psr-15) - [northwoods/broker](https://packagist.org/packages/northwoods/broker)
- [PSR-16 Common Interface for Caching Libraries](https://www.php-fig.org/psr/psr-16)

    - *DynamoDB* - [app/Caches/DynamoDbCache.php](app/Caches/DynamoDbCache.php)
- [PSR-17 HTTP Factories](https://www.php-fig.org/psr/psr-17) - [laminas/laminas-diactoros](https://packagist.org/packages/laminas/laminas-diactoros)

roadmap
-------

[](#roadmap)

### done

[](#done)

- Configuration - [PHP-DI](https://php-di.org/) stores configuration in [config](config) folder.
- Service providers - [Standard service providers](https://github.com/container-interop/service-provider/) wire up required classes using *PHP-DI*.

    Define service providers in [app/Providers](app/Providers) folder, and add the class to `app.providers` config in [config/app.php](config/app.php).
- Global middleware - [Broker](https://github.com/northwoods/broker) handles *PSR-15* middleware pipeline.

    Define middleware in [app/Http/Middleware](app/Http/Middleware) folder, and add the class to `http.middleware` config in [config/http.php](config/http.php).

    Ensure that the first middleware handles exceptions, and the last one handles routing.
- Logging - [Monolog](https://github.com/Seldaek/monolog) sends logs to the `stderr` stream which is relayed to *CloudWatch* by *AWS Lambda*.
- Routing - [FastRoute](https://github.com/nikic/FastRoute) routes are defined in [routes](routes) folder.
- Templating - [Latte](latte.nette.org/) for rendering templates in [templates](templates) folder.
- Database - *PDO* connections and queries work as expected. The function must be in the same `VPC` as the `RDS` cluster.

    There is also [AsyncAws RDS Data Service](https://packagist.org/packages/async-aws/rds-data-service).
- Event Handling - Add new event listeners by extending `ListenerProviderInterface` in a service provider.

    Look at [app/Providers/EventServiceProvider.php](app/Providers/EventServiceProvider.php) for an example of how to add a listener.

    Type-hint `Psr\EventDispatcher\EventDispatcherInterface` to get a dispatcher and dispatch as per *PSR-14*: `$dispatcher->dispatch(new MyEvent());`
- Queues - A regular event handler with an SQS event source works as expected.
- Cache - *PSR-16* *DynamoDB* cache in [app/Caches/DynamoDbCache.php](app/Caches/DynamoDbCache.php).

    Type-hint is `Psr\SimpleCache\CacheInterface`. Look in [template.yaml](template.yaml#L47) at the definition of the *SimpleTable*.

    The key created is `key`, the cached value is stored in `value` as a *gzip* compressed serialized version of the data, and the `expires_at` value store a *UNIX* timestamp in seconds.

### todo

[](#todo)

#### general

[](#general)

- Cache TTL.
- CORS.
- Form method spoofing.
- Validation.
- Content negotiation.
- Ad-hoc commands.

#### routing

[](#routing)

- Named routes.
- Reverse routing (URL generation).
- Route middleware.
- Rate limiting.
- Route cache.
- Resource controllers.

#### middleware

[](#middleware)

- Middleware groups.
- Middleware priority.
- Controller middleware.
- Authentication middleware using Cognito.
- Basic authentication.

#### files

[](#files)

- Uploaded files.
- File downloads.
- File responses.
- Static assets via S3.

bottom of the list
------------------

[](#bottom-of-the-list)

- Cookies.
- CSRF protection.
- Session.
- Scheduler.
- Migrations.
- ORM.

###  Health Score

17

—

LowBetter than 6% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity0

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity36

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/48372fbab9c5059c6d5773bb3d42dff0382443ceb65d008fc219ad38a383eafd?d=identicon)[datashaman](/maintainers/datashaman)

---

Top Contributors

[![datashaman](https://avatars.githubusercontent.com/u/59514?v=4)](https://github.com/datashaman "datashaman (125 commits)")

### Embed Badge

![Health badge](/badges/datashaman-phial-project/health.svg)

```
[![Health](https://phpackages.com/badges/datashaman-phial-project/health.svg)](https://phpackages.com/packages/datashaman-phial-project)
```

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
