I'd like to setup a profiler for my company's ZendFramework and Doctrine installation. Right now I have a bar at the bottom that shows up when on a dev environment that gives some basic timing and query counts (much like the Symfony profiler bar). What I'd like to do, is store all of that information and more in a SQLite database and allow viewing of that information in a profiler like Symfony allows.
Is there a way that allows me to include a module with my company's library where all of the code for this profiler can sit? Ideally, I'd want it setup so that a developer could type in "domainname.com/CompanyProfiler" and it would show them the full screen profiler. It doesn't seem like there currently is a way for me to make that routing possible without a new module.
Edit: After seeing the answer about setControllerDirectory, I looked into the front controller methods and found addModuleDirectory, which sounds like exactly what I need. But I can't get it to work.
$frontController->addModuleDirectory(APPLICATION_PATH . '/../library/Company/modules');
If I do a getControllerDirectory after that, I see:
'profiler' => '{really long correct path}../library/Company/modules\profiler\controllers'
In the "controllers" folder, I have IndexController.php with a class name of:
class Profiler_IndexController extends Zend_Controller_Action
But if I try to go to the URL "/profiler", I get a controller not found error. Any thoughts on what I'm doing wrong?
If I var_dump the errors in my error controller, I can see that it is clearly trying to access the default module.
If I understood right, you also want to have the controllers in the library? If so, you can set that ZF looks for CompanyProfiler module where all the controllers are in the library (or anywhere else) using setControllerDirectory().
Try adding a direct route to the module by placing the following in your bootstrap:
protected function _initRoutes()
{
$router = Zend_Controller_Front::getInstance()->getRouter();
// Route for profiler
$route = new Zend_Controller_Router_Route(
'profiler/:controller/:action/*',
array(
'module' => 'profiler',
'controller' => 'index',
'action' => 'index'
)
);
$router->addRoute('profiler', $route);
}
Related
I am very new to web scraping, It's been several days that I am dealing with the same problem:
Please look at the below line of code(extracted directly from the web page):
< option value='pick' id='ember2314' class='x-option ember view'>To Pick</option
whatever I do I can't access that class:
driver.find_element_by_class_name('x-option ember view') #when I want to print the text here, it says unable to locate element.
But for some other cases, I can easily access the class, and sometimes for some cases, I can't access the class.
Can anyone please shed some light on this? (sorry, I am very new to web scraping)
Please note that the 'id' and 'value' are changing every time so I can't rely on them.
Any help would be much appreciated.
Thanks,
For the people who are beginners like me, here is the solution. It is easy to search it with it's xpath:
//tagename[#attribute='value of the attribute']
so for this case:
driver.find_element_by_xpath('//option[#class="x-option ember view"]')
would do the trick.
From my understanding, the 'class' here is actually an attribute of the tag 'option', so search it like this: find_element_by _class_name('x-option ember view') won't give you anything.
I have a controller MyUsersController with an action login.
I have mapped this with:
$routes->connect('/member/login', [ 'controller' => 'MyUsers', 'action' => 'login', 'plugin'=>false, 'prefix'=>FALSE]);
Now I can access this action "login" using these two urls which is not good for SEO.
http://localhost/cakephpapp/member/login
http://localhost/cakephpapp/my-users/login
So, how can I disable the second URL?
I have tried this code which is working fine but I don't know whether this is correct method or not.
$routes->redirect('/my-users/login', '/member/login');
There is a line in the default routes file that provides the fallbacks so that you can access pages using controller/action. This is really to help you quickly scaffold an app. In CakePHP 3 this is:-
$routes->fallbacks('InflectedRoute');
As commented in the file you can/should remove this line once you have set up the routes for your application. If you remove this it will also prevent your error logs from filling with errors like 'Missing Controller' which can be an issue on a production site, particularly if it is replacing an existing one.
In CakePHP 2 the equivalent line is this:-
require CAKE . 'Config' . DS . 'routes.php';
Removing these lines does mean that you will have to define all routes for your application, but that is probably a better practice than relying on automagic routes of Cake (or any framework). There's a good article on this by Phil Sturgeon: Beware the Route to Evil.
I build a internet application with multi languages. I setup everything well, it work when I call as an example site.com/fr/ I get all in france or site.com/en/ all in english.
I try to get these languages also in my zend_navigation url's like the example above.
for the navigation config I use the application.ini
I hope someone can explain this part or give me an example how I put the 'lang' parameter in the url build by zend_navigation trought the application.ini
With kind regards,
Nick
To get the selected language in the url of the navigation dont start the uri by '/foo/' but like 'foo/'
example application.ini
resources.navigation.pages.popular.label = nav_popular //zend_translate
resources.navigation.pages.popular.title = nav_popular //zend_translate
resources.navigation.pages.popular.uri = popular/
resources.navigation.pages.popular.resource = "popular"
I am wanting to do stuff with the Google Data API, the contacts specifically. The easist method i have found so far is using Zend. The problem I am having is adding the Zend framework. Does anyone know how to do this with WordPress?
Thanks
you can use "hardcoded" includes if you fail to setup autoloading ->
in /wp-content/themes/levitation/send.php insert to the first line:
require_once 'your/path/to/zend/Zend/GData/ClientLogin.php';
Problem is you need to get through all the errors and alwas include the missing class (inside classes are the includes taken care of...
Or in the main file (guess index.php) insert:
set_include_path(get_include_path() . PATH_SEPARATOR . 'your/path/to/zend/');
//for ZF below 1.8
require_once 'Zend/Loader.php';
Zend_Loader::registerAutoload();
//for ZF > 1.8
require_once 'Zend/Loader/Autoloader.php';
Zend_Loader_Autoloader::setFallbackAutoloader(true);
It should be pretty trivial.
Write and test some bootstrap code that sets up ZF's autoloading and make sure it generally works.
Stick that code in a wordpress plugin, and tie things up to the right hooks in wordpress.
Try this http://blueberryware.net/2008/09/04/wp-library-autoloader-plugin
I think all you need is there.
Make sure that you are calling:
Zend_Loader::loadClass('Zend_Gdata_ClientLogin');
before you are using that class. And that you have a developer key.
I have a problem. Basically, depending on whether a user goes to /es or /br or /cn etc on our website, we have different language template files. So far, we were using a custom templating engine to make this work, but are making a switch over to ZF. I can't seem to figure out how to get ZF to look for a view script in say cn/about-us if the language varuable is cn.
I can't (don't want to) use Zend_Translate for this because we have way too many translated template files and it's just not feasible using Zend_Translate for bazillion different files with multi-paragraphs of Chinese/Korean/Japanese, forgetting for a second that I don't speak those languages.
Can anybody help me?
You can write a controller plugin and use it's routeStartup() method to alter Zend_View settings (path to where your view scripts are located) and change the request uri before routing starts.
class My_Controller_Plugin_LanguageSwitcher extends Zend_Controller_Plugin_Abstract
{
public function routeStartup(Zend_Controller_Request_Abstract $request)
{
// examine the $_SERVER['REQUEST_URI'] and look for your language identifier
// fetch the View and set appropriate view scripts path using setScriptPath() method
// strip the language identifier from your REQUEST_URI
// change the request uri using $request->setRequestUri('your-new-uri-without-the-language- identifier');
}
}