Comments (5)
There is an example of routing using annotations right there in the answer. Have you checked it out?
from elnurabstractcontrollerbundle.
Yes, and thank you for your patience sir. I am just very confused about what is supposed to go inside "routing.yml" when you are defining controller as service AND using annotations for config. Any example?
from elnurabstractcontrollerbundle.
Man, Elnur, please. I'm still stuck friend.
The problem here, is I'm not sure what to put in Routing.yml when using Controller as a Service using your abstract parent class AND annotation routing.
I have the following Routing.yml file:
WebController:
resource: "HostingPick\Controller\WebController.php"
type: annotation
This is according to how you specify - with making Vendor/Controller in order to take controllers outside of bundle.
But I get this message:
Cannot import resource "HostingPick\Controller\WebController.php" from "/home/dir/trunk/HostCore/app/config/routing.yml". (The file "HostingPick\Controller\WebController.php" does not exist (in: /home/dir/trunk/HostCore/app/config, /home/dir/trunk/HostCore/app/Resources).)
Man, the thing is, this "resource" expects link to Controller file INSIDE a bundle:
resource: "@HostingPickWebBundle"
The above example works, when my WebController.php file is in HostingPick/Bundle/WebBundle directory. But this defeats the point of your example, for controllers to live outside of any bundle.
How to specify to 'resource' that my controller (which is defined as service), is outside of bundles??
Pls man, I'm not crazy. This is not common sense to me. How can your solution work with this constraint? what can I put in resources?
Here is other relevant config:
jms_di_extra:
locations:
all_bundles: false
bundles: [WebBundle]
directories: ["%kernel.root_dir%/../src"]
services:
WebController:
class: HostingPick\Controller\WebController
parent: elnur.controller.abstract
from elnurabstractcontrollerbundle.
Here's how I do it in routing.yml
:
user:
resource: Elnur\Controller\UserController
type: annotation
As you can see, I have no .php
at the end.
And here's how that controller starts:
<?php
namespace EP\Controller;
use Elnur\AbstractControllerBundle\AbstractController;
use JMS\DiExtraBundle\Annotation\Service;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
/**
* @Service("user_controller", parent="elnur.controller.abstract")
* @Route(service="user_controller")
*/
class UserController extends AbstractController
Setting the service
option on the controller wide @Route
is important. I'm sure you can convert this to YAML if you prefer that format.
from elnurabstractcontrollerbundle.
Thank you :) 🎱
from elnurabstractcontrollerbundle.
Related Issues (8)
- Symfony2 logging HOT 4
- How to redirect with ElnurAbstractController HOT 1
- Unit testing when controllers are outside bundles HOT 1
- Do I need to manually create new Swift_Mailer instance with this controller? Accessing service container HOT 8
- How to inject SF2 Container? HOT 1
- Embedding Controller HOT 1
- Passing parameters from parameters.yml to abstract controller HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from elnurabstractcontrollerbundle.