PHP framework that can be included in other projects - php

I have a little specific concern, I hope you can help me, I have to develop an application in PHP that doesn't need to be linked to the exclusive use of its installation and could be used or "included" in other projects of PHP, I mean, to develop a web application (such as generation of a graph according to certain parameters passed) that can be used on different pages created for example in phpBB, Drupal, Dreamweaver or PHP Frameworks like CodeIgniter and Zend.
The best example of what I mean is "Google Charts Tools", you just print in the browser the access to the tool with the parameters and the tool does the rest, and this does not depend on the type of framework with which the home page was created.
In short, I'm looking for a framework or lightweight framework with which I can develop an application that simply could be called in an include() or require() on the destination page and can be used, a framework that can somehow "export" the project or application and could be used on one page without having to reinstall the framework on the target server, even the libraries could be included in the target page so you can run the application.
Was working with Codeigniter and tried to attach to a Joomla page but i couldn't because Codeigniter is linked to the URL of the page and I dont want to use Iframes.
Is there something like that?

First of all; I believe you would need some custimization, as frameworks just aren't build that way. But it isn't impossible. In Kohana for example (also codeigniter, but kohana is more flexible), you can build internal requests with Request::factory($uri). If you can find out a way to bypass direct access to index.php, or build a wrapper after which you can do stuff in the Kohana 'environment' you could do it. I don't have a ready-to-use solution, but if you try something and post the code we might be able to help you out some more!

Sounds to me like you want to write a library or class that can do certain things and which can be reused in other code. You can then build an example application around it, using a framework, which uses this library.
If you start with a whole framework, this often makes it really hard to reuse any part of the code, since the framework has certain assumptions or requirements which may not always be true for other projects. As a general rule: a framework is already a complete standalone application. What you want is something smaller than that.
Of course, you can have a look at a framework like Zend, which is basically just a loose collection of individual classes. Together they form a framework, but each part of it is individually usable. Something like CI is on the other end of the spectrum, much more heavily coupled and interdependent.

Related

Using Laravel with an existing website

I have an existing website running on PHP, MySQL CSS, JS and Ajax.
For future projects, I would like to use the Laravel framework to create new pages or functionality to the existing website... let's say a blog, for instance.
Is this possible?
Is the Laravel framework compatible with an existing website that is not set up using the MVC framework?
The reason is that I would like to make my work easier and more efficient and the use of a framework would be helpful.
Please let me know if you need any other info, I know the question is a little broad.
Thanks,
Justin
yes it's possible but of course maybe with difficulties.
you should put your web files in /views directory, convert your php files to controllers or library files and put your assets in /public directory.
then you can assign routes to your controller and call it form outside of the application.
main job is put your code into controller or libraries. is it possible to split your code into separate logical units? and extract model logic (as php mvc says) from your main code.
so if you have a clean code with good design and minimum dependencies you can think more about it. this could be a good challenge if you go through it cautiously. be careful to not fail and waste your time.

How would I use the Joomla Framework vs. creating Joomla extensions?

I have experience with Joomla and have modified and wrote some simple Joomla extensions. I don't have experience using one of the popular PHP frameworks (such as CakePHP), but I was thinking about using the Joomla framework because I'm familiar with Joomla. How would I use the Joomla framework for a software project instead of using regular Joomla and writing the extensions needed for it to extend it's capabilities? Thanks!
The basic idea is that you:
Get a copy of either the whole framework or just the packages you need+dependencies (from github or composer) or use the older copy that is shipped with the CMS,
Bootstrap your application (JApplicationWeb or JApplicationCli).
Write your code using the MVC structure provided.
The big difference with writing a totally independent application is that you are doing just that, you need to build everything in the application whereas in the CMS there are already a lot of things in place. (The good part of that is that you can make new code with no legacy concerns.) For example, if you look at the JIssues project you'll see that they had to think about things like authentication. So as you would expect writing a simple application is simple, writing a complex one is complex.
You can see many examples of framework applications around, ranging from the ones found in the CLI folder of your CMS installation to JIssues, and of course the three web applications in the CMS are all examples of applications on the framework.
The Joomla Framework is intended (among other things) to be the platform upon which you can build a web-application. The framework is like the frame of one of those motorcycles they build on "American Choppers." It provides the backdrop so that you can hit the ground thinking about your app without worrying about User Authentication, database connection, and a thousand other things like those that get in the way of bringing your app to its potential audience.
If you're trying to extend Joomla, the current edition is what you should be using.

Is there any technique to use Yii within Wordpress?

I am familiar with WordPress environment and wp developement.
Now I want to extend my knowledge with YII framework of PHP and I am learning things over YII.
I want to know if any technique or trick exist to use YII within WordPress for theme and plugin development.
Looking for your answers :)
Yes, it's quite doable. Read my article about it here: http://www.yiiframework.com/wiki/322/integrating-wordpress-and-yii-still-another-approach-using-yii-as-the-router-controller/
Note: it isn't that straightforward, so if you are new to Yii it may get complicated fast. But feel free to ask on the forums and we'll see if we can get you going.
I'm also going to put up a base Yii/Wordpress setup on Github at some point. If you subscribe to that article, you should get a notice when I do.
Edit: GitHub repo here: https://github.com/acorncom/yii-wordpress-integration
Not easily. WordPress is not written using the Yii framework, and most of the tasks that Yii would implement (database abstraction, request routing, caching, etc.) are already handled by WordPress in totally incompatible ways.
As others have noted, it's possible to integrate the two, but it's an awkward fit. You may want to consider first whether it would make more sense to use either Yii or WordPress alone.
Yes. You can read Using Yii in 3rd-Party Systems section from the Definite guide to Yii for more information:
Yii can also be used as a self-contained library to support developing and enhancing existing 3rd-party systems, such as WordPress, Joomla, etc. To do so, include the following code in the bootstrap code of the 3rd-party system:
require_once('path/to/yii.php');
Yii::createWebApplication('path/to/config.php');
The above code is very similar to the bootstrap code used by a typical Yii application except one thing: it does not call the run() method after creating the Web application instance.

May I use zend framework together with php files not using it

I am now working in a team to build a website using php. Told that Zend framework can be fairly convenient, I hope to use it to write the pages. However, some of the members in the team did not use the framework in their previous works. I do not know whether there will be any possible problems if their works are used together with mine? So I wonder whether it is possible for us to use Zend frameworks for part of the website while other members of the team do not use this framework to build the rest of the website? Thank you.
i not really sure to undersand your question
but it's look complicated to use ZF for a part of the site, and PHP for the other. However, it's possible. You can, with a .htaccess say that an URL is not define by ZF (i ever used it for a blog attached on a ZF site)
Don't hesitate to comment for any other answer
It depends on how you are splitting up the work. Zend Framework is modular so you are not tied into using the whole framework. You can just select the components you need. I would advise that you use one framework for your application startup and routing at least. Merging these part would be a hassle to maintain imo.

Are there any limits in using a PHP framework?

I'm planning to use a PHP framework (Yii) for my future project due to the amount of features that it would contain. I have done a few PHP projects in the past and I now realize how disorganized they can get after a while, even if you use a proper directory structure. So, basically, I'm wondering if everything in PHP, can also be done in a framework without tweaking the core framework itself. Will there be any limits? Can I use PHP classes like geolocation, phpexcel or phpthumb: http://phpthumb.gxdlabs.com? Preferably Yii. Thank you!
I'm wondering if everything in PHP, can also be done in a framework without tweaking the core framework itsel
No, every framework has its limits but some are more flexible than others. For example, some frameworks don't allow you to connect to multiple data-sources with their model implementation. But if it's a decent framework, you should be able to extend or swap out those shortcomings with your own or another implementation.
Can I use PHP classes like geolocation, phpexcel or phpthumb
Yes, most frameworks allow easy integration with other libraries. I found a link showing how to integrate phpexcel with Yii:
http://www.yiiframework.com/wiki/101/how-to-use-phpexcel-external-library-with-yii/
Yes All framworks have proscons, but it's very important that how we will user them, i.e cakephp provide the helper class to create html and form but no need to use each and every time that because it will make slow your application
CakePHP have also cache memory limitation, we found in one popular auction script.

Categories