Open Sorien opened 9 years ago
This looks good to me :+1:
How's this for the routes section?
"routes": {
"route name": {
"controller" : "FooClass::barMethod", // Or some kind of signature
"requirements": {
"foo": "\d+"
},
"defaults": {
"foo": 1234
}
}
}
yep, something like that we will see in future what everything we need
Although I have to say I cringe at version constants in code. They are a pain for release management. Is that maintains cost worth having the version info?
This is going to be a major version increment for the PHP side, right?
"version" : "1.0" .. it's just major format change just to detect why parsing fails/no routes in autocomplete and so on "silex" : "2.0", as well maybe we can use it for some optimization or disable certain functionality based on major silex version
Silex one, I'm fine with since they provide the constant - why not! Version....yeah it makes sense :/ Hard to be against it.
I have to ask: Any reason why the plugin can't have an Indexer like the Symfony2 plugin, that's makes this unneeded?
hmm, as far as i know s2 plugin still needs dumped DI container and its a bit easier to parse xml/yaml then run throw PHP AST and search for return type from closure registering service ... short answer don't know how to do it and don't have so much free time to find it out.
"dumped DI" are just one of the sources for "PHP AST" see annotations implementation, but its definitely harder in silex to do it, because of closures: https://github.com/Haehnchen/idea-php-symfony2-plugin/blob/master/src/fr/adrienbrault/idea/symfony2plugin/stubs/indexes/AnnotationRoutesStubIndex.java
just imagine this example every provider can modify session_storage_class before its used when retrieving session_storage .. there is no way how we can detect proper type without running whole code
$container['session_storage'] = function ($c) {
return new $c['session_storage_class']($c['cookie_name']);
};
Yeah that makes sense. But this is only a pimple limitation. Can other things like routing not be figured out without dumping them?
(Not to discredit this structure change)
i was planing to mix indexer and dump problem of routes from indexer is that's difficult to find out if provider was registered or not and you can use custom loaders like
$app['routes'] = $app->extend('routes', function (RouteCollection $routes, Application $app) {
$loader = new YamlFileLoader(new FileLocator(__DIR__ . '/../config'));
$collection = $loader->load('routes.yml');
$routes->addCollection($collection);
return $routes;
});
@Haehnchen maybe you will know, is there any way how to implement custom stub indexer (StringStubIndexExtension) for plugin?
t think you can use EnumeratorStringDescriptor
: https://github.com/Haehnchen/idea-php-symfony2-plugin/blob/master/src/fr/adrienbrault/idea/symfony2plugin/stubs/indexes/RoutesStubIndex.java
moreover if you need the routes itself. they are already inside the symfony2 plugin index
current one is not extensible
propesed one file
silex.meta.json
notpimple.json