PHPackages                             aol/atc - 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. [API Development](/categories/api)
4. /
5. aol/atc

AbandonedArchivedLibrary[API Development](/categories/api)

aol/atc
=======

ATC is a small dispatching library for PHP built on Aura.Router and Symfony's HTTP Foundation

1.0.6(10y ago)163.4k3MITPHP

Since Jan 21Pushed 9y ago22 watchersCompare

[ Source](https://github.com/aol/atc)[ Packagist](https://packagist.org/packages/aol/atc)[ RSS](/packages/aol-atc/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (8)Versions (10)Used By (0)

ATC, An Action-Based PHP Dispatching Library
============================================

[](#atc-an-action-based-php-dispatching-library)

[![Build Status](https://camo.githubusercontent.com/301bd921b0f4e9640fd2d894d80af1abc8d6bf63226c5c1a353f70a3b01748c2/68747470733a2f2f7472617669732d63692e6f72672f616f6c2f6174632e706e67)](https://travis-ci.org/aol/atc)[![Latest Stable Version](https://camo.githubusercontent.com/b18baadc29eae8c4a9d12ae8eead423336f03f853aa47fbe121b8384d0d106a7/68747470733a2f2f706f7365722e707567782e6f72672f616f6c2f6174632f762f737461626c652e706e67)](https://packagist.org/packages/aol/atc)[![Latest Unstable Version](https://camo.githubusercontent.com/c3194ec24cc2dec02c2c78999226e881912b12c898fb93b4747e4e7700c310f3/68747470733a2f2f706f7365722e707567782e6f72672f616f6c2f6174632f762f756e737461626c652e706e67)](https://packagist.org/packages/aol/atc)[![Total Downloads](https://camo.githubusercontent.com/5535973e8a0bea65a65ea34745b41043dfa790ae09cbcee4a788f185ac7cfcb0/68747470733a2f2f706f7365722e707567782e6f72672f616f6c2f6174632f646f776e6c6f6164732e706e67)](https://packagist.org/packages/aol/atc)[![Code Climate](https://camo.githubusercontent.com/5a559654b902837107518f552e87c5cf31d38747177a2bbda8df7e991437d6c2/68747470733a2f2f636f6465636c696d6174652e636f6d2f6769746875622f616f6c2f6174632f6261646765732f6770612e737667)](https://codeclimate.com/github/aol/atc)

ATC is a small dispatching library for PHP built on [Aura.Router](https://github.com/auraphp/Aura.Router) package and Symfony's [HttpFoundation](https://github.com/symfony/HttpFoundation) and [EventDispatcher](https://github.com/symfony/EventDispatcher). There are two things you should know about this library:

1. Every single route matches to a single Action class.
2. Exceptions thrown from the Action can implement the ActionInterface and become the new Action.

**"What's an action?"** You can think of an Action as a Controller with a single method. Rather than being responsible for many different routes/pages it is only responsible for a single route.

Usage
-----

[](#usage)

The simplest possible way to use ATC is by just setting up a route and a corresponding action. Lets do a simple hello world for our home page with an Action called Index.

```
$router->addGet('Index', '/');
```

```
namespace Your\Namespace\Prefix;

class Index extends \Aol\Atc\Action
{
    public function __invoke(Request $request)
    {
        return Response::create('Hello world');
    }
}
```

Now any requests for the home page `/` will match the `Index` Action and send a "Hello world" back to the browser. Remember, this is just using Aura.Router so its pretty easy to build complex paths with named parameters.

```
$router->addGet('Index', '/{name}/');
```

```
class Index extends \Aol\Atc\Action
{
    public function __invoke(Request $request)
    {
        return Response::create('Hello ' . $this->params['name']);
    }
}
```

### Leveraging the presenter

[](#leveraging-the-presenter)

While the method above would be great for simple API responses often you need to be able to do more complex things with templating libraries. ATC will always evaluate the return value of your Action and if it is a Symfony response object it will just send it straight to the browser. If it is not a response object it will take that data and hand it off to the Presenter to handle formatting.

There is an interface for the Presenter class - which makes it very easy to drop in your templating package of choice - but out of the box ATC will handle JSON responses and basic PHP templates. By default it will render the HTML template, but if the request header for the content type is set to `application/json` it will send the json encoded version of your action response. You can always lock an Action down to a single response type by setting the `$allowed_formats` property.

```
class Index extends \Aol\Atc\Action
{
    protected $allowed_formats = ['text/html'];
    protected $view = 'index';

    public function __invoke(Request $request)
    {
        return ['name' => $this->params['name']];
    }
}
```

```

Hello
```

### Exceptions can be Actions too

[](#exceptions-can-be-actions-too)

Any exception thrown from an ATC Action can immediately replace the current Action as long as implements the `ActionInterface`. Yep, you read that correctly, exceptions can be actions too. For example, if you throw the `NotAuthorizedException` from your Action the dispatcher will verify the exception implements the `ActionInterface` and then redispatch the request using the exception action. In this case it will respond with a `401` HTTP response code and look for a `errors/401` template to use in the presenter.

```
class Index extends \Aol\Atc\Action
{
    public function __invoke(Request $request)
    {
        throw new \Aol\Atc\Exceptions\NotAuthorizedException;
    }
}
```

You could also create custom exceptions within your own application. For example you could have a `NotSignedInException` that returns a `RedirectResponse` to the signin page:

```
class NotSignedInException extends \Aol\Atc\Exception
{
    public function __invoke(Request $request)
    {
        return new RedirectResponse('/signin/');
    }
}
```

The flexibility is unparalleled and the possibilities are endless.

Setup
-----

[](#setup)

The dispatch class itself can be instantiated with just a few dependencies.

```
$router = (new \Aura\Router\RouterFactory())->newInstance();
$request = \Symfony\Component\HttpFoundation\Request::createFromGlobals();
$action_factory = new \Aol\Atc\ActionFactory('Your\\Namespace\\Prefix\\');
$presenter = new \Aol\Atc\Presenter(__DIR__ . '/your/view/dir/');
$event_dispatcher = new \Aol\Atc\EventDispatcher;
$exception_handler = new \Aol\Atc\EventHandlers\DispatchErrorHandler;

$dispatch = new \Aol\Atc\Dispatch(
    $router,
    $request,
    $action_factory,
    $presenter,
    $event_dispatcher,
    $exception_handler
);

$response = $dispatch->run(); // Returns a symfony response object
$response->send();
```

Installing via Composer
-----------------------

[](#installing-via-composer)

ATC supports PHP 5.4 or above. The recommended way to install ATC is through [Composer](http://getcomposer.org).

```
# Install Composer
curl -sS https://getcomposer.org/installer | php
```

Next, run the Composer command to install the latest stable version of ATC:

```
composer require aol/atc
```

After installing, you need to require Composer's autoloader:

```
require 'vendor/autoload.php';
```

FAQ
---

[](#faq)

**WTF is "ATC"?** It originally stood for "Air Traffic Control" but that's a lot of typing and doesn't roll off the tongue very well.

**How do I inject dependencies into my Action classes?** The included ActionFactory is just the bare bones, but you can inject your own factory into the Dispatcher as long as it implements the `ActionFactoryInterface`.

**What about Twig/Smarty/Blade/etc?** Like the ActionFactory you can inject your own presenter class into the dispatcher as well as long as it implements the `PresenterInterface`. There are a lot of possibilities here so if you do something cool let us know!

**I think I found a bug, now what?** Please, open up an issue! Make sure you tell us what you expected, what happened instead, and include just enough code so that we can reproduce the issue.

**Will you add feature X?** Maybe, but you'll never know until you ask. Open up an issue and we'll discuss it and if you're interested in submitting a pull request check out the Contributing section below.

Contributing
------------

[](#contributing)

ATC is an open source project and pull requests are welcome if you'd like to contribute. Please include full unit test coverage and any relevant documentation updates with your PR.

License
-------

[](#license)

ATC is licensed under the MIT License - see the LICENSE file for details

###  Health Score

36

—

LowBetter than 82% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity26

Limited adoption so far

Community18

Small or concentrated contributor base

Maturity69

Established project with proven stability

 Bus Factor1

Top contributor holds 88.9% 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.

###  Release Activity

Cadence

Every ~50 days

Recently: every ~34 days

Total

7

Last Release

3833d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/0487962caaf1bd04a4707b82c195c46b04dfc589f3e2f473a68e0b4b628abd4c?d=identicon)[jakeasmith](/maintainers/jakeasmith)

![](https://www.gravatar.com/avatar/e2bf767c58e7679899cdc29a36452c5f33f439fa330824c996ac801646caf1ac?d=identicon)[ieatkillerbees](/maintainers/ieatkillerbees)

---

Top Contributors

[![jakeasmith](https://avatars.githubusercontent.com/u/234832?v=4)](https://github.com/jakeasmith "jakeasmith (56 commits)")[![baileylo](https://avatars.githubusercontent.com/u/145345?v=4)](https://github.com/baileylo "baileylo (5 commits)")[![stoph](https://avatars.githubusercontent.com/u/415988?v=4)](https://github.com/stoph "stoph (2 commits)")

---

Tags

dispatcherphp

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/aol-atc/health.svg)

```
[![Health](https://phpackages.com/badges/aol-atc/health.svg)](https://phpackages.com/packages/aol-atc)
```

###  Alternatives

[sylius/sylius

E-Commerce platform for PHP, based on Symfony framework.

8.4k5.6M651](/packages/sylius-sylius)[drupal/core

Drupal is an open source content management platform powering millions of websites and applications.

19462.3M1.3k](/packages/drupal-core)[sulu/sulu

Core framework that implements the functionality of the Sulu content management system

1.3k1.3M152](/packages/sulu-sulu)[contao/core-bundle

Contao Open Source CMS

1231.6M2.4k](/packages/contao-core-bundle)[freshcells/soap-client-bundle

SoapClientBundle for symfony

35151.0k](/packages/freshcells-soap-client-bundle)[tamara-solution/php-sdk

Tamara PHP Client Library

10259.4k1](/packages/tamara-solution-php-sdk)

PHPackages © 2026

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