PHPackages                             nicolascharpentier/silex-simple-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. nicolascharpentier/silex-simple-annotations

ActiveLibrary[Framework](/categories/framework)

nicolascharpentier/silex-simple-annotations
===========================================

Provide annotations for silex

10372[1 issues](https://github.com/NicolasCharpentier/silex-simple-annotations/issues)PHP

Since Jan 3Pushed 9y ago1 watchersCompare

[ Source](https://github.com/NicolasCharpentier/silex-simple-annotations)[ Packagist](https://packagist.org/packages/nicolascharpentier/silex-simple-annotations)[ RSS](/packages/nicolascharpentier-silex-simple-annotations/feed)WikiDiscussions master Synced yesterday

READMEChangelogDependenciesVersions (2)Used By (0)

silex-simple-annotations
========================

[](#silex-simple-annotations)

Warning
-------

[](#warning)

Not recommanded for production, as it has no cache, and the project is unfinished (but working).

When is the last time you dreamed of annotations for every controller route?
----------------------------------------------------------------------------

[](#when-is-the-last-time-you-dreamed-of-annotations-for-every-controller-route)

Silex Simple Annotations allows you to get rid of controller providers and have it done your(our) way.

Prepend your controller function with annotations. We will deal with the rest.

```
    /**
     * @Path /login
     * @Method POST
     * @Bind user.login
     */
    public function loginRegisterAction(Application $app, Request $request)
    {
        $user = SomeSuperStaticClass::loginOrRegisterThisGuy($request, $app);
        return $app->json();
    }
```

This examples links a `POST` on `baseUrl/SomeControllerPrefixRouteYouGave/login` to the `loginRegisterAction` action

Why should I use this provider?
-------------------------------

[](#why-should-i-use-this-provider)

Currently, there seem to be only 2 providers after a quick Google search

-
-

They both use `Doctrine\Annotations` to parse annotations and seem to work.

So why?

- You hate Doctrine (strange)
- You want a simple syntax
- You are lazy and just want to provide your `/src` for controllers
- You may need an automatic documentation. *This will come in the future*

Why not?

- These other providers are probably faster for parsing
- I'm french

What can i do? Is this FREE?
----------------------------

[](#what-can-i-do-is-this-free)

### Registering

[](#registering)

First, add this to your composer.json dependencies

```
"require": {
    "other/packages...": "...",
    "nicolascharpentier/silex-simple-annotations": "dev-master"
  },
```

Then register the following service provider wherever you do so for your project:

```
$app->register(new SilexSimpleAnnotations\AnnotationsServiceProvider(), array(
    'simpleAnnots.controllersPath' => __DIR__ . '/../src/Controller',
    'simpleAnnots.recursiv' => false, // Optional, default to false,
    'simpleAnnots.controllersAsApplicationAwareServices' => false // Optional, default to false. Will instanciate controllers with $app as services
));
```

Parameters start with **simpleAnnots** and end with:

- **controllersPath** : String or Array of controller directory/ies
- **recursiv** : Boolean, if true the search for controllers will be .. recursiv. Not recommanded for optimization.

### Using

[](#using)

Loop the following for each controller you want to be annotation-equiped.

1. Give a prefix for the controller (which will be prepend for every action route)

    ```
    /**
     * @Prefix /user
     */
    class UserController {
    ```
2. Pimp your actions

    ```
    /**
     * @Path /logout
     */
    public function logoutAction(Application $app)
    {
        AbstractUserManager::disconnectCurrentUser($app);

        return $app->json();
    }

    /**
     * @Path /stalk/{id}
     * @Bind user.stalkhim
     */
    public function stalkAction(Application $app, $id)
    {
        AbstractUserManager::disconnectCurrentUser($app);

        return $app->json();
    }
    ```

    This will mean

    - a `GET` on `/user/logout` will call the `logoutAction`, which will be binded to `user.logout`
    - a `GET` on `/user/stalk/1` will call the `stalkAction`, with `$id === '1'` and the bind on `user.stalkhim`
3. Test and enjoy!!

Available annotations
---------------------

[](#available-annotations)

- **Controller Level**

    - **Prefix** *REQUIRED*
    - Sets the route prefix for every actions, also will be used for the default binding value.
    - *eg.* /user
- **Actions Level**

    - **Path** *REQUIRED*
    - Sets the Route suffix.
    - *eg.* /edit/{id}
    - **Bind** *OPTIONAL*
    - Sets the Route binding.
    - Default to Prefix + '.' + actionName (`str_replace($function_name, 'Action', '')`)
    - *eg.* user.edit
    - **Method** *OPTIONAL*
    - Sets the request method.
    - Default to GET
    - Value(s) accepted GET POST PUT OPTIONS DELETE
    - *eg.* POST PUT

TODOS
-----

[](#todos)

- Get why the ordered list on this README just displays '1' at every step.
- Support multiple methods for a Route
- Modify the Rules class to be more self explanable
- Generalize annotations usage when building Controllers
- Implement a cache system
- Start implementing the automated documentation

Ps: Not working on this at the moment, still checking for issues.

Feedback &amp; Contribution
---------------------------

[](#feedback--contribution)

Any sort of feedback is strongly encouraged and will be listened.

Also feel free to contribute or just ask for change, even the smallest

> "No more controller provider needed. Got my wife back. Love this" - George, Alabama.

> "This is awesome, my legal e-commerce website got 200% more purchases" - Ben, Thailandia.

###  Health Score

24

—

LowBetter than 31% of packages

Maintenance18

Infrequent updates — may be unmaintained

Popularity15

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity43

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 91.7% 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://avatars.githubusercontent.com/u/9944995?v=4)[nicolas.charpentier78@gmail.com](/maintainers/NicolasCharpentier)[@NicolasCharpentier](https://github.com/NicolasCharpentier)

---

Top Contributors

[![NicolasCharpentier](https://avatars.githubusercontent.com/u/9944995?v=4)](https://github.com/NicolasCharpentier "NicolasCharpentier (33 commits)")[![Steve-A-Orr](https://avatars.githubusercontent.com/u/4119409?v=4)](https://github.com/Steve-A-Orr "Steve-A-Orr (2 commits)")[![nahakiole](https://avatars.githubusercontent.com/u/4542479?v=4)](https://github.com/nahakiole "nahakiole (1 commits)")

### Embed Badge

![Health badge](/badges/nicolascharpentier-silex-simple-annotations/health.svg)

```
[![Health](https://phpackages.com/badges/nicolascharpentier-silex-simple-annotations/health.svg)](https://phpackages.com/packages/nicolascharpentier-silex-simple-annotations)
```

###  Alternatives

[laravel/socialite

Laravel wrapper around OAuth 1 &amp; OAuth 2 libraries.

5.7k104.3M836](/packages/laravel-socialite)[laravel/dusk

Laravel Dusk provides simple end-to-end testing and browser automation.

1.9k38.6M289](/packages/laravel-dusk)[nineinchnick/edatatables

Grid widget for the Yii Framework, wrapper for the DataTables jQuery plugin

173.2k](/packages/nineinchnick-edatatables)[link-cloud/fast-hyperf

LinkCloud Fast Hyperf

241.2k1](/packages/link-cloud-fast-hyperf)

PHPackages © 2026

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