Can individual classes from CodeIgniter be integrated into other frameworks / projects without using the underlying framework to build the application?
I believe this can be achieved in Zend if I only wanted to use specific classes (such as Zend_DB, Zend_Validate, etc…) by linking to just that component without needing to use the underlying framework for building the application. Can someone please confirm this? In addition, what other frameworks (e.g., Symphony, CakePHP) have this ability, specifically CodeIgniter?
Just look at the class definitions and see what they depend on. Likely they are tightly coupled to the rest of the framework.
ZF was defined from the beginning as a collection of components, or tools, which is why stealing individual classes is so easy - it was intentional.
CI is meant to be extremely loosely coupled, so perhaps OP will have some luck. I don't have any examples however
Related
I'm wondering if ZF2 is based entierly on MOVE instead of the classic MVC.
Somewhere I read that is really bases on MOVE (http://cirw.in/blog/time-to-move-on) but e.g. in the "getting started tutorial" (http://zf2.readthedocs.org/en/latest/user-guide/overview.html) they are saying "creating a simple database driven application using the Model-View-Controller paradigm".
So, what is it now based on? Does it support both?
I'm a bit confused. What are the difference at MVC between ZF1 and ZF2?
Thanks
MOVE (Models, Operations, Views and Events)
MVC (Models, Views, Controllers)
The problem with MVC is that you end up stuffing too much code into controllers,
to overcome this problem MOVE is another possible option to choose in zf2 projects,
Because in this architecture you can split your controller into Events and Operations.
Question: Is ZF2 based entirely on the MOVE architecture?
I don't think ZF2 is designed entirely on MOVE architecture.
ZF2 follows the SOLID object oriented design principle with loosely coupled MVC architecture which provide more flexibility in terms of usability.
Question: Can I develop my projects using the MOVE architecture in ZF2?
Yes ZF2 provides you with everything to support both architectures (MOVE, MVC).
It provides Models, Views, Controllers(Operations), Events.
It is up to the developer which architecture he would like to use.
ZF1 and ZF2 is compared in another thread.
MVC or MOVE
SOLID Object Oriented Programing
I am still a beginner in zf2, I am writing here since I had ported my zf1 code entirely to new zf2 framework. I could only say the new framework have lot of advantages and once you get certain new concepts and feature. you can save lot of time developing new project by reusing of modules/components etc.
In zf2 most of the library components are designed to be standalone, i.e loosely coupled, as said it gives more flexibility and a task can be done in many ways (just like PHP is). The main advantage I see is modules, I can split my project to many modules with ease and test individually and integrate very easily without any additional codes. Even I had all my resources like images, css and JavaScript files inside my module folders and access it without any problem (off course with a small code in index.php)
for me ZF1 has fixed rules, flows, etc, and zf2 have liberated flow and rules with new addition of events namespace, configuration and lazy loading, assemble objects, inject dependencies with servicemanger. in zf1 routes are automatic(programmatic), where as in zf2 we need route definition, in zf1 controllers are automatically choosen, where as in zf2 we need to define controllers as invokables, this are few things that take some time to get in once you get the idea you will feel the comfort of using the new zf2 framework
to start with you can do this steps
Learn Service Manager
How Configuration works
How events work
Components wise more or less it works the same as in zf1 (at least in my case)
below are the following advantage I had benefited
Full feel of OOP
Modular application development
Design and then develop to PHP application
Web Application(RIA) platform
I'm not sure if this is possible, but let's say you want to build a CMS, but you're torn between 2 frameworks because each has some features that you like. Is it possible to create the CMS with both framewoks? Does this approach have merits or pitfalls?
Speaking strictly about the Zend Framework (ZF) I would say yes. ZF components are written to be as independent from other components as possible. I would say that it would not be very difficult (It may actually be quite common) to integrate libraries of ZF into other frameworks like Cake, Symfony, or Codeigniter.
Is it possible to create the CMS with both framewoks?
While it's possible to use components from the Zend Framework inside other Frameworks / CMSs - this may be the case with other component libraries as well, but Zend's the most modular one that I know - It's usually not a good idea to mix two full-blown Frameworks.
Many central functions like MVC structures, URL routing, the database layer, Unit testing, error management and so on are by nature unable to be served by two frameworks at once without massive friction. Also, you're likely to get problems when one of the frameworks needs to be updated.
I would recommend to pick the framework that covers most of what you need, and try and add the missing features using plug-ins or own modifications.
Your question is too abstract.
For instance Zend Framework is more to be a library of specific functionalities ready-to-be-include into Your codebase then some closed development environment like for instance Symfony framework.
Thanks to it can be ZF simply included into your codebase (and Symfony too).
Symfony Framework compared to it is closed solution depending on front server environment so you cannot use it like some other framewor's slave.
It would really depend on which things you liked about both...
Zend Frameowrk is more like a library, so you can pick and choose components from it. Symfony also has some re-usable components you can use.
Really, you can do anything... it just depends how much work you want to do, and how willing you are to modify the framework code. Note: most other PHP frameworks are not nearly as flexible as Zend Framework (next up probably being Symfony).
This sounds very messy, so I'd advise against it, unless you use it in the fashion I've described above. It's easy to pull ZF or Symfony components into other frameworks, but not the other way around.
Hope this helps.
The composability of most frameworks is such that that is most likely to give you all the disadvantages of both, while simultaneously eliminating most of the individual advantages of both.
It seems to me like one framework will for serve as the core - bootstrapping, MVC stack, routing - while the other will be used to pull in specific functionality - like classes for forms or filtering or interacting with web services, etc.
As much as I prefer Zend Framework for the core - and most everything else - its use-at-will architecture argues for making the other framework the core and pulling in ZF components where you need them.
As #Adrian notes, it's easy to pull in ZF components into a project built primarily on another framework, since ZF is designed with that flexibility in mind. Other frameworks are less accommodating in this regard.
You can do it. Most modern frameworks (Zend, symfony, flow) is capable to use parts of other frameworks. Symfony 2 uses Zend Logger, flow3 uses sfYaml... It is possible tu interchange some components.
But, imho, you should stick to one framework as a core, and use second only to relatively isolated subsystems. Adapter and Facade design patterns can help you to mix them together - some components / clases demands some wrapping before use in non-native environment.
For further reading: http://www.symfony-project.org/book/1_2/17-Extending-Symfony#chapter_17_integrating_with_other_framework_s_components
Of course it is possible and I don't see something wrong with it. For example I used CakePHP and Zend on a relatively large Project which was kind of a cms. CakePHP for the core (Routing, MVC) and Zend for some "Modules". Mainly for PDF, E-Mail (smtp), FTP and a few others that CakePHP was not that good at. With Cake it was fairly easy to use ZF components and didn't feel hacky at all.
In fact, ZF was written to be as independent as possible, so that you can use any component at any time anywhere. Yet, it would not work the other way round (Using ZF as core, and Cake components). Surely it is possible, but a real pain with no benefits. So ZF could be used propably inside of pretty much any other framework and nothing would be wrong with it, imho.
could someone give an example of the meaning of this word?
i read about that prado is a component-based framework and i wonder if cakephp and codeigniter are too?
A component based framework basically means that you can pick and choose the elemnts of the system you want without having to refactor those individual elements themselves. Zend Framework is a good example.
Usually the opposite is highly couple framework like CakePHP or RoR. In these cases it is much harder to divorce and individual component like the Router or Controller and use it outside that framework's stack.
In general you want to minimize tight coupling so you get the most out of reuse and have the most flexibility in terms of replacing components or modifying them. The thing i find i often dont like about component frameworks is that while the individual components are often well designed and have a default way of working with each other often a ton of development time isnt poored into automation of using the tools together. Take Zend Framework for example. GREAT COMPONENTS, however with 1.10 we finally see a decent commandline tool to automate setup and initialization of modules/controllers/views etc.. There wanst a defined bootstrapping process/convention until 1.8 i think it was... For me this is one of the most important parts. Something highly boasted by RoR, Django, Cake, Symfony, CodeIgniter and others.
I was wondering if anyone knew how to use some components of the Zend Framework without having to actually use the framework. For example, I would like to use their Zend_Validate components, but don't want the overhead of the framework as it's a small one-page script.
Can this be easily done, and if so, are there guides/tutorials on how to accomplish it?
Zend framework components are intentionally designed to be loosely couple from the framework itself.
The component structure of Zend
Framework is somewhat unique; each
component is designed with few
dependencies on other components. This
loosely coupled architecture allows
developers to use components
individually. We often call this a
"use-at-will" design. [from here]
Here's a tool for pulling out specific components and their dependencies to use in your application.
I've just grabbed the whole Zend package, and used pieces of it. It always seems I end up using more of it as time goes on, so I keep it up to date even if I'm not using some of the MVC stuff in one project or another. Holding on to the whole thing makes you not have to worry about the dependencies (and how they might change down the road).
Zend framework components while being loosely couple are still coupled. If you would to use Zend_Mail component for example - that would actually also require:
Zend_Mime
Zend_Exception
Zend_Validation
Zend_Validation will be loaded for the mere reason of validating email address domain.
So - best bet would be to include entire Zend library. By pulling only several components - you'll soon end up in "dependency hell" especially as API changes (though that doesn't happen too often).
Also - starting from version 2.0 you must use some auto-loader to load Zend components as all require calls will be removed from PHP classes.
Duplicate of
What is a PHP Framework?
and many more
So far, I've been using PHP for small tweaks, mostly with WordPress. What are PHP frameworks? Why do I need them? WHEN do I need them?
Any insight will be helpful. Thanks.
Frameworks are organized groups of code or libraries, built on top of a language to either
Make Common Tasks Easy/Simple
Create a Consistent Way to Develop Applications
Some frameworks are very restrictive (as in it's not easy to do things, unless you do them the 'framework' way), others are looser. I've found Zend's Framework to be a good mix of both, making easy to use single components (for example, you can drop the 'Feed' library into your existing application without needing to rewrite the application the Zend way), or you can use the Zend MVC and Application libraries to for an entire application.
I'd stay away from frameworks that are 'all or nothing'.
From Zend's Framework (restating the above, perhaps more completely):
Zend Framework is an open source framework for developing web applications and services with PHP 5. Zend Framework is implemented using 100% object-oriented code. The component structure of Zend Framework is somewhat unique; each component is designed with few dependencies on other components. This loosely coupled architecture allows developers to use components individually. We often call this a "use-at-will" design.
While they can be used separately, Zend Framework components in the standard library form a powerful and extensible web application framework when combined. Zend Framework offers a robust, high performance MVC implementation, a database abstraction that is simple to use, and a forms component that implements HTML form rendering, validation, and filtering so that developers can consolidate all of these operations using one easy-to-use, object oriented interface. Other components, such as Zend_Auth and Zend_Acl, provide user authentication and authorization against all common credential stores. Still others implement client libraries to simply access to the most popular web services available. Whatever your application needs are, you're likely to find a Zend Framework component that can be used to dramatically reduce development time with a thoroughly tested foundation.
A framework tries to provide all the things that are common to every (or most) projects - html rendering, database access, and so on - in a way that's simple and easy to use.
You would use one to speed development, because you can skip all that stuff, and focus on what's unique to your project. Depending on the one you use, it can also add some security features by automatically escaping data on the way to the database, or to the screen.
I use them in any situation where I don't need something so custom that it's more work to bend the framework to my needs than to create the whole thing from scratch. That's pretty rare.