Coder Social home page Coder Social logo

silex-annotation-provider's People

Contributors

danadesrosiers avatar dermanomann avatar iskandar avatar jdesrosiers avatar jsmith07 avatar marabesi avatar olivier34000 avatar solcik avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

silex-annotation-provider's Issues

Ignore route

Is there a way to ignore a route for a given URL?

For example, I don't want the annotation for the path:

http://localhost/foo

But at the same time I would like to have the annotations working in the root, like:

http://localhost

Cache Controller Reflection Metadata

here is my proposal

    public function registerController($controllerName)
    {
        /**
         * instead fetching reflection class, it build all class metadata
         */
        if ($this->cache->contains("annot.{$controllerName}.metadara") && $this->useCache) {
            $controllerMetadata = $this->cache->fetch("annot.{$controllerName}.metadara");
        } else {
            $controllerMetadata = $this->buildMetadata($controllerName);
        }

        if ($controllerMetadata["controller"]["annotation"] instanceof Controller) {
            $this->app['annot.registerServiceController'](trim($controllerName, "\\"));
            $this->process($this->app, $controllerMetadata);
        }
    }

Instead creating controller reflection class on registerController method it would be great performance improvement if it build all class metadata (methods & annotation) in simple array or object so it can be cached for future use.

Dependency injection

I am injecting into controller some factories and library is overriding PHP-DI and injecting into controller Silex\Application. Is there any workaround about this?

Annotation exception

Is there a way to remove a given route being automatically used by the annotations?

Today I've got a bunch of controllers registered in the service provider, but let's say, for whatever reason I'd like to use the route /foo/bar freely. How can I accomplish that?

obs: When I say freely, I mean without any annotation. Right know silex throws an exception saying 'Route not registered'.

Silex 2 Swagger

Hi there,

This is not so much an issue but shameless self promotion....

I've created a library that allows to use silex annotations together with swagger-php to generate swagger JSON from the annotations: https://packagist.org/packages/radebatz/silex2swagger.

If it turns out to be useful (I use it a lot...) it would be great if perhaps there could be a reference to it somewhere in your docs.

Cheers, mano

v2.1.0 ignores all controllers

Hello,

I have just updated to version 2.1.0 and all my routes are now ignored because of a combination of AnnotationService::getFiles() and AnnotationService::registerControllers() / AnnotationService::prefixMatchesUri().

AnnotationService::getFiles() builds an array which is indexed with both prefixes and indexes, then it is used by AnnotationService::registerControllers() in a foreach($controllers as $prefix => $controllerNames).
When my controller doesn't have a prefix, the position in the array is used as a prefix /0, /1 and so on, for example:

string(48) "Controller\CommonController"
string(7) "$prefix"
int(1)
string(2) "/1"

When my controller does have a prefix, it is re-prefixed by "/" which make the strpos function fail, for example:

string(57) "Modules\Administration\ApiController" (I am using multiple controller directories)
string(7) "$prefix"
string(19) "/administration/api"
string(20) "//administration/api"

Here's how I register the service provider

<?php
$this->register(
  new AnnotationServiceProvider(),
  [
    'annot.base_uri'      => '/',
    'annot.cache'         => new ArrayCache(),
    'annot.controllerDir' => [
      __DIR__.'/Controller/',
      __DIR__.'/Modules/',
    ],
  ]
);

I have, for now, regressed to version 2.0.1 so as to keep developing but I thought I would mention it here, be it an error on my part because I simply run composer update or a code error. I am running PHP 7.2 on Apache 2.4 on Windows 10 x64.

Thank you,
Bruno Buiret

composer is not getting silex2 version

I have my minimum-stability set to dev, but composer update barfs on your composer install instructions

Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - The requested package ddesrosiers/silex-annotation-provider ~2.0@dev exists as ddesrosiers/silex-annotation-provider[1.1.x-dev, dev-master, v0.1.0, v0.1.1, v0.1.2, v0.2.0, v0.2.1, v1.0.0, v1.1.0] but these are rejected by your constraint.

Annotation context?

I was wondering if it would be possible to add a way to pass some sort of context (array/map/object) into the generated annotations? This would be very useful for me :)

The point is that it could allow to make the annotations behave differently depending on the environment, etc.

For example, I'd like to add an environment requirement, so some annotations are only active/used if the environment matches.

if this sounds like something useful I'd be happy to create a pull request...

Registering multiple directoris not working with Apcu Cache

I work with
Silex: v2.1.0
ddesrosiers/silex-annotation-provider: v2.0
doctrine/cache: v1.7.1
PHP: 7.1.5
Docker, FPM, Alpine

In my src/app.php configure AnnotationServiceProvider
php $app->register(new AnnotationServiceProvider(), [ "annot.cache" => new ApcuCache(), "annot.controllerDir" => [ ROOT_PATH . "/src/App/Controllers", ROOT_PATH . "/src/Core/Controllers" ] ]);
And only work routes in /src/App/Controllers, other routes show error "Route not found".
But i remove annot.cache and work fine

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.