Is it possible to use Symfony2 web profiler bundle with Zend Framework 1 or other framework? - zend-framework

I have existing project written in Zend Framework 1, it is long term project, constantly developed and without possibility of migrating to ZF2. It would be really neat to use Symfony2 Web Profiler bundle in it.
Currently, in development, I am using zfdebug (https://packagist.org/packages/spekkionu/zfdebug) which is great, but bundle from Symfony2 has so much more to offer...
I managed to incorporate Composer into my application (in Bootstrap), so loading something with it should be no problem. Also I found package on Packgaist (https://packagist.org/packages/symfony/web-profiler-bundle) but to be honest - I don't know if it is even usable without Symfony2.
Thanks for any tips.

No, this is not possible. If you take a look at the requirements on packagist you see it requires symfony/http-kernel, symfony/routing and symfony/twig-bridge to work. That's because the way the WebProfilerBundle works:
It registers himself at the most common events, the events happening in the HttpKernel and Routing component. If he cannot register to these events, he will not be able to give you timer information.
Moreover, it uses another event to inject imself in your page, meaning that if you don't have that event, you will never see the bar.
And the bundle is using Symfony conventions and techniques, meaning that it cannot run on ZF conventions and techniques. This is why it is called a Bundle instead of a Component, components are stand alone, bundles aren't.

Related

manipulating other modules functionality in zend framework 2

How can I manipulate other modules without editing them ? very the same thing that wordpress modules do .
They add functionality to core system without changing the core code and they work together like a charm.
I always wanted to know how to implement this in my own modular application
A long time ago I wrote the blog post "Use 3rd party modules in Zend Framework 2" specifically about extending Zend Framework 2 modules. The answer from Bez is technically correct, it could be a bit more specific about the framework.
Read the full post at https://juriansluiman.nl/article/117/use-3rd-party-modules-in-zend-framework-2, but it gives you a clue about:
Changing a route from a module (say, you want to have the url /account/login instead of /user/login)
Overriding a view script, so you can completely modify the page's rendering
Changing a form object, so you could add new form fields or mark some required field as not required anymore.
This is a long topic, but here is a short gist.
Extensibility in Zend Framework 2 heavily relies on the premise that components can be interchanged, added, and/or substituted.
Read up on SOLID principles: http://en.wikipedia.org/wiki/SOLID_(object-oriented_design)
Modules typically consists of objects working together as a well-oiled machinery, designed to accomplish one thing or a bunch of related things, whatever that may be. These objects are called services, and managed by the service locator/service manager.
A big part of making your module truly extensible is to expect your developers to extend a class or implement a certain interface, which the developer register as services. You should provide a mode of definition wherein the developers can specify which things he wants to substitute, and/or add their own services to -- and this is where the application configuration comes in.
Given the application configuration, you should construct your machinery a.k.a. module services according to options the developer has specified i.e., use the developer defined Foo\Bar\UserService service as the YourModule\UserServiceInterface within your module, etc. (This is usually delegated to service factories, which has the opportunity to read the application configuration, and constructs the appropriate object given a particular set of configuration values.)
EDIT:
To add, a lot can be accomplished by leveraging Zend's Zend\EventManager component. This allows you to give developers the freedom to hook and listen to certain operations of your module and act accordingly (See: http://en.wikipedia.org/wiki/Observer_pattern)

What functionality should go into Zend Framework modules?

I'm a bit puzzled about Zend Framework modules.
I mean - I understand that you would usually want to have frontend and backend module... right?
But - What else would you separate out into modules?
can someone who uses Zend Framework professionally give an example of what modules they have in their application?
In the Zend MVC lingo a module is an independent part of your application. For example if you want to write a Content Management System you will probably have different modules like
Main application (user login, application bootstrap etc.)
Blog
News
Admin panel
Image gallery
Basically each of these modules could act as a separate application (although they will eventually be interconnected). The module approach also gives you an easy way for permission management (e.g. users can only pay for using certain modules).
As addition to Daffs answers we could try to figure out some guidelines for deciding between choosing a 'controller' or a 'module' to implement a certain bundle of functionality. Please help making this list comprehensive by commenting or editing:
When to use a 'controller':
when there is a considerable degree of dependency on different models of the same module
when there is a considerable degree of interaction with other controllers of the same module
when the functionality can be covered with a few methods/actions
when the functionality is clearly just a bundle of subordinated functionality of the given module
when the functionality can be easily maintained together with the rest of the code (versioning, deployment, ...)
When to use a 'module':
when there are no or almost no dependencies with the main modules controllers and models
when the bundle of functionality can be seen as a separate (sub)application
when the functionality can't be covered with a few methods/actions and thus has to be broken down into several controllers
when versioning and deployment needs independence from main module

Need advice on removing zend framework dependency

I'm in the middle of converting an existing app built on top of zend framework to work as a plugin within wordpress as opposed to the standalone application it currently is.
I've never really used zend so I've had to learn about it in order to know where to begin. I must say that at first I didn't think much of zend, but it's funny because the more I understand how it works the more I keep questioning why I'd want to remove dependency when it's a clearly well thought out framework. Then I'm reminded that it's because of wordpress.
Now I already know there are WP plugins to make zend play nice with WP. In fact I'm aleady using a zend framework plugin just to get the app functional within the WP admin area which is allowing me to review code, modify code, refresh the browser, review changes, debug code, again and again.
Anyway, I really don't have a specific question but instead I'm looking for advice from any zend masters out there to offer advice on how to best go about a task like this one.... so any comments, advice, examples or suggestions would be super.
One area I'm a little stuck on is converting parts of zend->db calls to work as wpdb calls instead... specifically the zend->db->select.... not sure what to do with that one.
Also on how to handle all the URL routing with automatic calls to "whatverAction" within thier respective controllers files.
Any help would be great! Thanks
You're probably facing an uphill battle trying to get some of the more major components of ZF to work in harmony with Wordpress. It sounds like you've got a full MVC app that you're trying to integrate into a second app that has very different architecture.
You probably want to think about which components handle which responsibilities. Wordpress has it's own routing and controller system that revolves around posts, pages and 'The Loop'. This is entirely different from Zend's Action Controllers and routing system.
It's possible you could write a WP hook to evaluate every incoming request and decide if it should be handled by WP or a ZF controller. However, it is doubtful you would be able to replace WP's routing system outright with ZF's or vice versa.
Same idea, where Zend_Db is concerned. There's nothing stopping you from using Zend_Db to access Wordpress's database, but trying to somehow convert or adapt Zend_db calls into wpdb calls sounds painful. If you have a large model layer, you probably want to hang on to it, and find a way to translate data from those models into the posts/pages conventions that Wordpress uses.
Personally, I would use ZF to build a robust business layer that can be queried through an object model via a Wordpress plugin, and then rely on Wordpress to do the routing and handle the views.
Zend_DB_Select is simple SQL query (but created using objects) that can be used like any other query. Just turn it into string. Ex.:
mysql_query((string)$zendDbSelectObject);

GWT Dynamic Module Loading

Is there a mechanism to dynamically load a GWT Module?
The idea is to create a pluggable GWT-based system: a core GWT module that dynamically loads another GWT module and a bus communication system to permit the communication through loaded modules.
Any help?
Possible duplicate of Web Application using OSGi and GWT
Also, see the information in this GWT User forum thread - http://groups.google.com/group/google-web-toolkit/msg/4a3f912cb89a7256
To summarize, its possible, but not recommended. Your requirement is orthogonal to GWT's philosophy and architecture. If you must, the GWT Exporter project is a useful starting point to enable communication between modules.
Code splitting does successfully handle the separated-loading issue -- but it does not address the separated-compilation issue.
Modular-interoperability with separated-compilation will never be the recommended default but GWT team should look into this in future.
If we are talking about a plug-in based architecture, different plug-in developer should develop their own UI and compile and give to the framework. Framework should dynamically load them.
I am still looking for and way to do it (do it better way).
You can use code splitting to dynamically loading the code when ever you want.
Have a look
http://code.google.com/webtoolkit/doc/latest/DevGuideCodeSplitting.html
See also comments at http://code.google.com/p/google-web-toolkit/wiki/CodeSplitting, starting at 6th comment.

Using the Validation Block of Enterprise Library with Entity Framework

We've used the Validation Block of MS Enterprise Library for some time with great success in conjunction with custom DALs but we've recently started using the Entity Framework and can't get the Validation Block to work with it. The objects are dynamically created in EF and putting attributes on top of them will simply get wiped out when the models are re-genned.
Can these two co-exist? If not, does anyone have any recommendations for what validation library/simple rules engine would be a good candidate to use along with EF?
Thank you.
You need a validator which supports a "buddy class" (like this example for Dynamic Data). This seems to be a work in progress for VAB. I can't find an example of anyone actually using it yet, but it might work.
Validation Application Block supports the concept of configuration based validation. This way you can separate your generated domain entities from validation. You can use the Enterprise Library configuration tool for this. Simply right-click on your configuration file and start adding validation configuration.
I advise you to read the VAB Hands on Lab document (ValidationHOL.pdf) which is included in the Hands On Lab download. After reading that document, read this article. It explains how to integrate VAB with Entity Framework.
Good luck.