PHPackages                             enstart/croute - 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. enstart/croute

ActiveLibrary[API Development](/categories/api)

enstart/croute
==============

Create routes using annotations in your controllers doc blocks

08PHP

Since Oct 9Pushed 8y ago1 watchersCompare

[ Source](https://github.com/enstart/croute)[ Packagist](https://packagist.org/packages/enstart/croute)[ RSS](/packages/enstart-croute/feed)WikiDiscussions develop Synced 2mo ago

READMEChangelogDependenciesVersions (2)Used By (0)

Enstart Extension: Croute
=========================

[](#enstart-extension-croute)

> This extension is still in development and should not be used in production until there's at least one tagged release.

Create routes using doc block annotations in your controllers doc blocks. You will still be able to use the default way to create routes.

### Dependencies:

[](#dependencies)

- `enstart/core` version 0.2+
- PHP 7.0+

### Install

[](#install)

```
composer require enstart/croute

```

### Config:

[](#config)

```
// Settings
'croute' => [
    // Enable the parser
    'enabled'     => true,

    // Use the cached file, if it exists
    'use_cache'   => false,

    // Path to the cache
    'cache'       => '/path/to/cache/folder',

    'controllers' => [
        // Namespace => path
        'App\Controllers\Api' => __DIR__ . '/app/Controllers/Api',
    ],
],

// Register the service provider
'providers' => [
    ...
    'Enstart\Ext\Croute\ServiceProvider',
],

```

### Access the extension

[](#access-the-extension)

```
// Get a copy of the instance
$croute = $app->container->make('Enstart\Ext\Croute\Parser');

// or through the alias:
$app->croute

// or through dependency injection (if you type hint it in your constructor)
use Enstart\Ext\Croute\Parser;

```

### Annotation

[](#annotation)

Below is a simple method annotation

```
class TestController
{
    /**
     * Get list of items
     *
     * @route GET /items
     *
     * @return json
     */
    public function list()
    {
        return $this->makeJsonEntity(true, ['list of items']);
    }
}

```

This will register the route `/items` with the GET method.

#### Route prefix for the whole class

[](#route-prefix-for-the-whole-class)

```
/**
 * @routePrefix /test
 */
class TestController
{
    /**
     * Get list of items
     *
     * @route GET /items
     *
     * @return json
     */
    public function list()
    {
        return $this->makeJsonEntity(true, ['list of items']);
    }
}

```

The above will register the route `/test/items`. All method routes in the above class will have the `/test`-prefix.

#### Optional route settings

[](#optional-route-settings)

Just like the normal router, you can add things like filters and named routes:

```
/**
 * Get list of items
 *
 * @route GET /items
 * @routeName list-items
 * @before filter1|filter2|...
 * @after  filter1|filter2|...
 *
 * @return json
 */
public function list()
{
    return $this->makeJsonEntity(true, ['list of items']);
}

```

The annotations `@before` and `@after` can also be used for the class annotations.

### Caching

[](#caching)

...more info will come.

###  Health Score

20

—

LowBetter than 14% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity43

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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/5b76b7dacecd8eb1d06b6404f80ab39df555a5f0c687276feb45c21388633ce3?d=identicon)[enstart](/maintainers/enstart)

---

Top Contributors

[![magnus-eriksson](https://avatars.githubusercontent.com/u/3640297?v=4)](https://github.com/magnus-eriksson "magnus-eriksson (1 commits)")

### Embed Badge

![Health badge](/badges/enstart-croute/health.svg)

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

###  Alternatives

[stripe/stripe-php

Stripe PHP Library

4.0k143.3M480](/packages/stripe-stripe-php)[twilio/sdk

A PHP wrapper for Twilio's API

1.6k92.9M272](/packages/twilio-sdk)[knplabs/github-api

GitHub API v3 client

2.2k15.8M187](/packages/knplabs-github-api)[facebook/php-business-sdk

PHP SDK for Facebook Business

90121.9M34](/packages/facebook-php-business-sdk)[meilisearch/meilisearch-php

PHP wrapper for the Meilisearch API

73813.7M114](/packages/meilisearch-meilisearch-php)[google/gax

Google API Core for PHP

263103.1M454](/packages/google-gax)

PHPackages © 2026

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