Tagged: zf2 doctrine profiler
2014/03/23 at 1:48 pm #285
I’ve been trying for weeks, but I don’t know what to do to make the DoctrineProfiler work in my test application.
I read page 123 of the book :
“The implementation of ProfilerAwareInterface and the Database Profiler initializer will guarantee that we will have access to the ZF2 profiler.”
I see that DoctrineProfiler implements ProfilerAwareInterface, but I don’t understand what is Database Profiler initializer : is it MyModule/Service/Initializer/DbProfiler ?
If yes, even if I replace “database-profiler” with “doctrine-profiler” in DbProfiler, it doesn’t work.
What can I do ?
Thanks2014/03/25 at 10:27 pm #288
First you have to make sure that you have in module/User/src/User/Service/Invokable/DoctrineProfiler.php the content from here: https://github.com/slaff/learnzf2/blob/master/module/User/src/User/Service/Invokable/DoctrineProfiler.php
Then in your module.config.php for the User module you should add the following line under the service_manager key
<?php return array( //.... 'service_manager' => array( // ... 'invokables' => array ( 'doctrine-profiler' => 'User\Service\Invokable\DoctrineProfiler', ) );
You will find the code above in line 67 in that file: https://github.com/slaff/learnzf2/blob/master/module/User/config/module.config.php#67
> I see that DoctrineProfiler implements ProfilerAwareInterface, but I don’t understand what is Database Profiler initializer
When you decide to get an instance of the doctrine profiler using the service manager what will happen is that based on the definition
'invokables' => array ( 'doctrine-profiler' => 'User\Service\Invokable\DoctrineProfiler', )
It will create an instance of the User\Service\Invokable\DoctrineProfiler class. After this instance is created there is an initializer called Database Profiler initializer, defined in the Debug module configuration ( Line 12 in this file: https://github.com/slaff/learnzf2/blob/ch-doctrine/module/Debug/config/module.config.php#12 ) :
'service_manager' => array( //.. 'initializers' => array( 'Debug\Service\Initializer\DbProfiler', ), //..
That will check if the newly created object is instance of ProfilerAwareInterface and if yes it injects the database profiler.
If you skipped reading some chapters and jumped directly the Doctrine Profiler section I recommend you to go back and read carefully “Database Profiling” to see from where comes the database profiler initializer.2014/03/26 at 6:53 pm #289
Thank you for this answer; it helps me, but what is the correspondence for “database-profiler” in DbProfiler.php ?
You wrote : “When you decide to get an instance of the doctrine profiler using the service manager …” : I realize that I don’t understand where to place this code to get this instance …
I know you’re very busy, but I’ve read several times your book (I’ve even bought the paper and the PDF versions because I thought something was lacking somewhere…).
Thank you2014/03/26 at 7:56 pm #290
Here is the message I get in the “Bottom Line” area :
Fatal error: Call to undefined method Cine\Service\Invokable\DoctrineProfiler::getProfiles() in D:\Zend\Apache2\htdocs\cinesiope\module\Cine\view\cine\layout\sidebar.phtml on line 12“2014/03/28 at 12:59 pm #291
Hi Philippe, I am getting the feeling that something is wrong with your service manager configuration. Let’s do the following: put the source code of your application in a guthub repository and share it with me. I can take a look over it and make changes related to the database profiling and doctrine profiling. This way you can easily observe the changes that I will make.
Does it sound like a plan to you?2014/03/28 at 2:22 pm #292
I feel honored. Thank you very much.
I’m going to do according your proposal. I just need a few days to make it as clean as possible!
Regards2014/04/03 at 9:12 pm #295
Here is my repo (it’s the first time for me!)
It’s a test project. Do you need a sample of my database ?
I started from the ZendframeworkSkeleton and I add codes from here and there (it was before I read your book)…It’s the reason why it’s dirty !
This project includes DoctrineModule and DoctrineORMModule.
I’d like to have the doctrine profiler work with Cine\Controller (list action) and see the result with sidebar.phtml as you did.
Thank you very much to take time for that.2014/04/07 at 1:30 pm #296
Take a look at the commits from today. If this does not help you to figure out how to use the doctrine profiler then read agian the chapter in the book related to Doctrine 2 and discuss it with fellow programmers 🙂2014/04/07 at 10:13 pm #297
Now I understand what was wrong and why it didn’t work.
Thank you very much
You must be logged in to reply to this topic.