I have inherited a PHP YII project and I'm trying to figure out what it has and does. I was wondering if it's possible to display all URLs that the project routes to.
Examples would be
index.php
<controller.php>/index
<controller.php>/search
<controller.php>/add
For all controllers and all views.
You must look to configs of UrlManager/rules. Here describes all rules for process requests. Than you will know what controllers and modules (even their actions) are using. Another way I don't know
Related
I need to set up two sites running from the same codebase in Laravel 4.2, I have done this before but I need some slightly different requirements this time.
Some of the assets CSS, JS and images would be the same but some would need to be overridden, I am happy to just have two public folders, with all front end assets duplicated, but if there are other suggestions that could make it easier that would be great.
My other requirement is that I would like to add a new PSR include route for site 2 that could override classes from site 1, when necessary. So I could call class user as below, site 1 would call the first class, site 2 would call the second class.
app/models/user.php
app/models/site-2/user.php
Well, you could set up both domains to use same Laravel project directory and then you could create middleware which would check for current domain name:
$currentDomain = $_SERVER['SERVER_NAME'];
Then you may just check for domain and decide what routes, controllers, models, views to use right now. I think this approach will solve you needs.
CI looks for Segment[1] for controller (in controller dir) and Segment[2] for Method. Now, I have specific requirement by business application which needs that I do not want CI to look or by force go to controller dir to load but I will have something like this "domainURL/module_identifier_id/controller/method/".
Here, every request will be coming along with its associated Module's Identifier ID which will have complete module's configuration and other data (controller files, module location where it was uploaded, all menus and their URLs which will have same URL mechanism which we want to design for developers to develop modules and upload) stored in DB.
We need to get this ID and play with it to fetch relevent records and point CI to load controller from where we want it and indeed rest for methods etc every thing needs to be working as it is.
I hope you understand what we are looking for that we have our own main controller type file where all of the requests will be coming with customizing protocol as described above and developers will be following it by all means, that there must be module identifier first and then controller, method etc...
Let me know if you have any query to be cleared on?
I think I would just use routes for this:
$route[(:any)/(:any)/(:any)] = '$2/$3/$1';
This should just rearrange your segments the way you want, without completely changing the way the native routing system works.
Alright, I know this is a bit localized, as I'm sure not many break out of traditional Zend Framework logic. But. This is a case where I have one main piece of software developed on ZF, and in it 3 different levels of platform.
So I have your stock folder structure of Zend Framework, then in it 2 additional sub folders that act as layers on top of the main structure. These sub folders have "layouts" "views" "controllers" and respectively "helpers" "scripts", etc.. so. With that due to how this was laid out I have run into a bit of a Jam, where I need to access a helper that is stored in one sub section from another sub section.
Normally you would access the helper like
$this->_helper->enrollHelper->isCreationDriven();
But, the controller I need to call this helper from is in another controller directory. Note I didn't build this app initially I am just helping enhance features and continue its growth. Anyway. The above line wont work for me in this case as the controller I want to call the helper from is outside of that directory in another like directory.
With that, My question is. Does anyone know a means I can call the helper in a similar fashion from this other directory? Or do I end up doing whats likely the obvious choice and just make a mirror copy of that helper in the other controllers directory where I want to call it from initially, my hope is there is a means as I want to avoid duplicate code.
During Bootstrap, you can register the second directory with the plugin broker using Zend_Controller_Action_HelperBroker::addPath($path, $prefix).
I'm working on a Zend Framework API and need to follow a particular format for URLs, so I was hoping for some help regarding how to configure the routing correctly.
http://example.com/module/controller/method/actionNameHere
The above URL would need to route to the function actionNameHereAction.
Any help is appreciated.
The beauty of routing is that it gives you the tools for hiding exactly those pieces of information you are putting into your URL.
Apart from that, as far as I know ZF routes by default so that your URL would end up in ...
the action with name method of
the controller with name controller of
the module with name module
So either your example-URL is complicating things or you are almost there.
B/c actionNameHere would be a paramter you could handle in your action with name "methodAction".
But I think you want your URL to look like:
example.com/module/controller/actionNameHere
In order to produce the URLs needed, I ended up creating a custom Dispatcher, as it wasn't in the routing that URLs were being converted from actionNameHere to actionnamehereAction, but in the dispatcher. I extended the standard dispatcher and overrode this behaviour so that the action name in the URL remained case-sensitive.
We have taken on a site written in Zend framework. We didn't write the site and haven't use the Zend framework before so I'm interested in finding three things.
How do I add new views to the site, adding in a new folder to the application/views/scripts directory seems to do nothing
Are there any tutorials on how to add affiliate feeds and setups to a zend site that you can recomend?
Are there any good tutorials on learning the framework? So far all I've found is vast amounts of material that confuses me
to answer your questions in order:
You have to find the controller, that will emerge the view you want to add. There are two ways to get a view script rendered. The first one is a naming convention on the view script. The view has to be the same name as the action name of the controller. Like "indexAction" and index.phtml. The other way is to instanciate a view object within the controller and give a string with the view name at runtime. You may want to look at this excerpt:
$view = new Zend_View();
$view->a = "Hay";
$view->b = "Bee";
$view->c = "Sea";
echo $view->render('someView.php');
which I took from http://framework.zend.com/manual/en/zend.view.controllers.html#zend.view.controllers.render
I don't think that I understand what you mean by "affiliate feed"... are you talking about advertising or is it more like content syndication?
The first thing you should read may be the Zend Framework Study Guide which you find here: http://www.zend.com/community/downloads. There are many tutorials an howtos out there but, this guide is made from Zend directly and should cover the main topics.
Regards,
Mario
Are you adding the appropriate Zend_Controller as well? The Zend_Controller QuickStart is a good place to get started with MVC.
You might also look at Zend_Tool, which provides a script to help create the necessary structure.
Basically, views need corresponding controller actions. So the main index action (located, for example, in application/controllers/IndexController.php) would need a corresponding view at /application/views/scripts/index/index.phtml.
example: To reach an action within the Index Controller named fooAction() you would need a view file at /application/views/scripts/index/foo.phtml.
example: To reach the index action of contact controller you would need the controller at /application/controllers/ContactController.php (with an indexAction() inside it) and the view at /application/views/scripts/contact/index.phtml.
Getting beyond the absolute basics... view rendering can also be turned off or redirected but that is getting beyond the basics. Also if the app uses Zend_Layout there will be a layout file located somewhere like application/layouts/scripts/layout.phtml
Clear, concise and current ZF info can be strangely hard to come by. For tutorials check out:
The ZF Quickstart
Rob Allen's tutorial
Some screencasts
For adding feeds I suppose you should check out the framework's documentation for Zend_Feed