PHPackages                             sageit/phalcon-micro-annotations - 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. [Framework](/categories/framework)
4. /
5. sageit/phalcon-micro-annotations

ActiveLibrary[Framework](/categories/framework)

sageit/phalcon-micro-annotations
================================

Sage IT Component for Phalcon - Annotations Parser for annotation routes

v1.00(3y ago)07MITPHPPHP &gt;=7.0

Since Dec 28Pushed 3y agoCompare

[ Source](https://github.com/SageITSolutions/phalcon-micro-annotations)[ Packagist](https://packagist.org/packages/sageit/phalcon-micro-annotations)[ RSS](/packages/sageit-phalcon-micro-annotations/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)Dependencies (1)Versions (3)Used By (0)

 [ ![Logo](.readme/logo.png) ](https://github.com/SageITSolutions/phalcon-micro-annotations)Phalcon Micro-Annotation
========================

[](#phalcon-micro-annotation)

[![Latest Stable Version](https://camo.githubusercontent.com/ad9c305585b19bd5484934c1cc4606cb028c2a28c359647f2a7ca87ac4a4a764/687474703a2f2f706f7365722e707567782e6f72672f7361676569742f7068616c636f6e2d6d6963726f2d616e6e6f746174696f6e732f763f7374796c653d706c6173746963)](https://packagist.org/packages/sageit/phalcon-micro-annotations)[![Total Downloads](https://camo.githubusercontent.com/73957822fb8357e964e0510423d29b17d19d820f39f2bc4f9e915b5c0ba86ec4/687474703a2f2f706f7365722e707567782e6f72672f7361676569742f7068616c636f6e2d6d6963726f2d616e6e6f746174696f6e732f646f776e6c6f6164733f7374796c653d706c6173746963)](https://packagist.org/packages/sageit/phalcon-micro-annotations)[![License](https://camo.githubusercontent.com/0f0bcf451086482da91d9b139b02bea8caaf0565fc33a261bc9581e2f34a65fd/687474703a2f2f706f7365722e707567782e6f72672f7361676569742f7068616c636f6e2d6d6963726f2d616e6e6f746174696f6e732f6c6963656e73653f7374796c653d706c6173746963)](https://packagist.org/packages/sageit/phalcon-micro-annotations)[![PHP Version Require](https://camo.githubusercontent.com/911d7b96905be36f9fa47d8ceaa5c958f306d29bbb674a030a78e78c16e2c05b/687474703a2f2f706f7365722e707567782e6f72672f7361676569742f7068616c636f6e2d6d6963726f2d616e6e6f746174696f6e732f726571756972652f7068703f7374796c653d706c6173746963)](https://packagist.org/packages/sageit/phalcon-micro-annotations)[![Phalcon Version](https://camo.githubusercontent.com/560a961c38315fffe98d6177cdb41c708f7729c570f5aef5bc38a32c84a9c45e/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f646570656e64656e63792d762f7361676569742f7068616c636f6e2d6d6963726f2d616e6e6f746174696f6e732f6578742d7068616c636f6e3f6c6162656c3d5068616c636f6e266c6f676f3d5068616c636f6e25323056657273696f6e267374796c653d706c6173746963)](https://packagist.org/packages/sageit/phalcon-micro-annotations)

 Allows you to use annotations for routing on Phalcon Micro Applications. While the built in Phalcon class for an annotation based router works on full suite Phalcon apps, Micro uses a different mounting methodology and does not support this. The Micro-Annotation Router leverages the build in Micro mounting method while allowing for annotation parsing with the caching method of your choice.

**[Explore the docs »](https://github.com/SageITSolutions/phalcon-micro-annotations)**

**[Report Bug](https://github.com/SageITSolutions/phalcon-micro-annotations/issues)** · **[Request Feature](https://github.com/SageITSolutions/phalcon-micro-annotations/issues)**

Table of Contents
-----------------

[](#table-of-contents)

- [About the Project](#about-the-project)
- [Installation](#installation)
- [Usage](#usage)
- [Caching](#caching)
- [Roadmap](#roadmap)
- [Contributing](#contributing)
- [License](#license)
- [Contact](#contact)
- [Acknowledgements](#acknowledgements)

About The Project
-----------------

[](#about-the-project)

### Built With

[](#built-with)

- [vscode](https://code.visualstudio.com/)
- [php 8.1.1](https://www.php.net/releases/8_1_1.php)
- [Phalcon 5](https://phalcon.io/en-us) (Micro Framework)

Installation
------------

[](#installation)

**Git:**

```
git clone https://github.com/SageITSolutions/phalcon-micro-annotations.git
```

**Composer:**

```
composer require sageit/phalcon-micro-annotations
```

Usage
-----

[](#usage)

This project consists of an included Router class extension which follows closely to the Phalcon 5 Namespace convention. Once a service is added in the micro app, this can easily be leveraged.

### Create a Service (Example)

[](#create-a-service-example)

```
namespace App\Service;

class Router implements \Phalcon\Di\ServiceProviderInterface
{

    public function register(\Phalcon\Di\DiInterface $di): void
    {
        $di->setShared(
            'router',
            function () use ($di) {
                return new \Phalcon\Mvc\Router\Annotations\MicroRouter($di, (object) [
                    "adapter" => "apcu",
                    "directory" => "app/controllers/",
                    "namespace" => "App\Controllers",
                    "lifetime" => 21600000,
                    "cachedirectory" => "/app/storage/cache/annotations/"
                ]);
            }
        );
    }
}
```

When creating the service, MicroRouter requires 2 parameters.

1. The Dependancy Injector the service is added to.
2. An Object containing optional settings.

*The provided example demonstrates the default values assumed if the option is ommited.*

### Mount Micro to the service

[](#mount-micro-to-the-service)

From within the Micro class call:

```
$this->getDI()->get('router')->mountMicro($this);
```

*this will pass the micro app (`$this`) to the parsor and call the micro mount method using the parsed annotions*

Caching
-------

[](#caching)

This class supports safeguarded Caching. You can choose between `APCu`, `Stream`, or `Memory` (Not Caching) when creating the router service to optimize usage.

### Specifying Cache Method

[](#specifying-cache-method)

Within the Options array passed to the MicroRouter, specify the adapter of choice.

**APCu**

```
"adapter" => "apcu",
"lifetime" => 21600000,
```

**APCu**

```
"adapter" => "stream",
"cachedirectory" => "/app/storage/cache/annotations/"
```

**Memory**

```
"adapter" => "memory"
```

*technically, `Memory` is the fallback when all others fail, so any value not APCU or Stream would resolve to memory*

### Safeguards

[](#safeguards)

Once specified, the class checks for the presence of the required components before using a caching method. This works in a tiered manner.

1. `APCu` is specified, checks are made if APCu is installed and enabled, if not the adapter will revert to Stream
2. `Stream` is specified (*or APCu specification failed*), checks are made that the directory specified for `cachedirectory` exists, if not adapter will revert to Memory
3. `Memory` is specified (*or result of reverting*), no checks are required, all parsing is done in memory each time.

### Parsing

[](#parsing)

When caching methods are enabled, they are processed first before iterating files producing I/O calls. If annotations are present, no files are parsed, and routes are generated from memory. When no annotations are present (*first call or after **clearing cache***) then Controller files are parsed from the provided `directory` and annotations are added.

### Clearing Cache

[](#clearing-cache)

A public utility method is included to facilitate the need to rebuild the cache either in testing or publishing scenarios. Clearing Cache is dependant on the adapter specified.

```
clearCache()
```

*From within the micro class*

```
$this->getDI()->get('router')->clearCache();
```

This will remove all APCu entries with the prefix `_phan` or removing all files in the `cachedirectory` depending on the adaptor type.

*if the dependancy injector identifies as `logger` service, the notices are logged indicating the cleared cache*

Roadmap
-------

[](#roadmap)

See the [open issues](/issues) for a list of proposed features (and known issues).

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

[](#contributing)

Contributions are what make the open source community such an amazing place to be learn, inspire, and create. Any contributions you make are **greatly appreciated**.

1. Fork the Project
2. Create your Feature Branch (`git checkout -b feature/AmazingFeature`)
3. Commit your Changes (`git commit -m 'Add some AmazingFeature'`)
4. Push to the Branch (`git push origin feature/AmazingFeature`)
5. Open a Pull Request

License
-------

[](#license)

Distributed under the MIT License. See `LICENSE` for more information.

Contact
-------

[](#contact)

Sage IT Solutions - [Email](mailto:daniel.davis@sageitsolutions.net)

Project Link:

Acknowledgements
----------------

[](#acknowledgements)

- [OakBehringer](https://github.com/OakBehringer/phalcon-micro-route-annotations)

###  Health Score

20

—

LowBetter than 14% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity42

Maturing project, gaining track record

 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.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

1235d ago

### Community

Maintainers

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

---

Top Contributors

[![DavisDS](https://avatars.githubusercontent.com/u/120134967?v=4)](https://github.com/DavisDS "DavisDS (3 commits)")

---

Tags

frameworkmicrophalconannotation

### Embed Badge

![Health badge](/badges/sageit-phalcon-micro-annotations/health.svg)

```
[![Health](https://phpackages.com/badges/sageit-phalcon-micro-annotations/health.svg)](https://phpackages.com/packages/sageit-phalcon-micro-annotations)
```

###  Alternatives

[slim/slim

Slim is a PHP micro framework that helps you quickly write simple yet powerful web applications and APIs

12.2k49.9M1.3k](/packages/slim-slim)[phprest/phprest

PHP Rest Framework.

3049.3k](/packages/phprest-phprest)

PHPackages © 2026

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