As far as I know, many PHP frameworks use syntactic sugar to provide illusion of real functions. Some provide scaffolding/skeleton generation, which is limited. Syntactic sugar is slow and IDE/editors do not provide intellisense for Syntactic sugar functions/methods and member data. I'm wondering if there any tool/framework to generate PHP code based on some popular frameworks and built around a relational schema? Thanks in advance.
I think Symfony has something that you might find interesting.
Try Zend Framework.
Zend Framework (ZF) is an open source, object-oriented web application framework implemented in PHP 5 and licensed under the New BSD License.
I found QCodo http://www.qcodo.com/wiki/article/background/metaprogramming which satisfies requirements. Thank you very much for participating. You all earned my vote.
Zend_Framework has code generator called Zend_Tool, tough it's still unstable.
Zend_CodeGenerator
For posterity, I thought I would mention the rather impressive solution I just found to this problem.
Zend_CodeGenerator was added to Zend Framework as of, I believe, version 1.8, and I'm very impressed with it so far. Like most ZF components, it works just fine as a standalone tool; you needn't implement the rest of the framework in your project.
So far it seems easy to use and quite powerful.
Have a look at Cygnite Framework's Crud generator. It is very simple and easy to use. The New Cool Kid build on Symfony2 console component, I found interesting, made my job simple and fast.
Cygnite CLI generates controller, model, views, layout, form component, required field validation, pagination etc. with a simple command.
php cygnite generate:crud controller_name table_name database_name
You may alter the code based on your need.
Have a look, may help someone.
Generate CRUD application within 2 minute
Cygnite Framework Code Generator
Related
I'm designing an e-commerce database for a school project that require usage of cakePHP.
The ORM « attempt » of cake (yeah, it's not really an ORM) doesn't fit my needs.
I tried doctrine 2, I'm not convinced by the complex DSL and some crazy behaviors.
What I'm searching is an ORM that make associations effort-less and use conventions like we can do it with Rails ActiveRecord.
Because of complexity of an e-commerce database, I can't test everything and advices on doing that in PHP will be appreciated
Just wanted to share our experience with PHP ActiveRecord.
We are using it in production on a commercial web app for 2 years. We chose it for its unmatched simplicity and because it uses PHP5.3 features to provide nice RoR-like methods.
For 2 years we never had any significant issues with the library. We update it from time to time to keep up to date and pretty happy with it.
PHP ActiveRecord won't suite everybody since, well, it's ActiveRecord, not true ORM. But as you are specifically looking for RoR-like ActiveRecord solution in PHP, look no further.
Laravel's Eloquent ORM is nice, it can take a little bit of work to get it standalone but it's worth it.
You may wish to search for composer ActiveRecord packages, there are dozens of them:
One of them which says it was inspired by RoR: https://github.com/jpfuentes2/php-activerecord
There are dozens of them: https://packagist.org/search/?q=activerecord
Or even try ruby on rails in your search https://packagist.org/search/?q=activerecord%20ruby%20on%20rails
Try at least a bit of your own research before asking questions, as well as showing what you have found and tried.
I'm looking for some kind of CMS or framework + ORM (I don't really know exactly what I'm looking for).
My goal is to build a web app to view and manage database records.
To help understand, I would like some sort of end-user phpmyadmin/CMS hybrid with minimal programming efforts. In fact, that is to build a database of a particular kind of products, where those are submitted and consulted by end user and validated by myself.
I first thought that wordpress + plugins, mediawiki + semantic or drupal could be quick solutions but
those are quite heavy for the purpose.
Playing with tons of plugins don't reassure me, as they can become unmaintained, conflicting, ..
Solutions like mediawiki requires bunch of time to write templates, etc..
Then I thought at using a framework (let's say symfony) but it's also very time-consuming (compared to an almost out-of-the-box solution).
Finaly, I thought that the quickest solution may be to develop it all by myself using an easy ORM (like RedBean), but I wish I could find a quicker solution.
Any idea ?
Note: I intend to use a php/mysql solution.
There are plenty of "micro-frameworks" for PHP that work very well with RedBean (which I love btw). It's a compromise between writing everything from scratch and using a full blown framework. I find their is a good degree of flexability using these small(ish) tool kits.
One I've used a little bit is Slim, which gives you routing and some other small things a controller would.
Other similar "micro-frameworks" like Slim:
Silex
Limonade
GluePHP (which is about 30 lines of code)
These all give you routing and some other neat tools. In regards to MVC, they sorta give you the C.
If RedBean is your Model, or the M, all your missing is the V, should you want the whole MVC organization.
For that you can use Smarty, Twig or Mustache, or any other templating tool.
I personally love working with these components separately, because I find that they are all highly specialized, integrate nicely, and allow me to control to what extent they are in charge of things. The downside is is that they may have compatibility issues with each other and that you have to maintain three, as oppose to one, third-party library to update and depend on their development.
Here's a good article on using Slim with Idiorm (an ORM) and Twig, though I find Idiorm rather nasty to work with.
Sounds like you could use:
asp.net + mvc or django
Sorry these are two different comparable environments that should help with not a lot of overhead on learning, and can function quite well with mysql
Is the Zend Framework similar in use in relation to PHP just like jQuery is used for javascript?
Only in the sense that thing A is written in thing B and attempts to make doing things C, D, and E easier for programmers using thing B.
Programmers have been writing libraries of code for their favourite language for decades. It's called 'not re-inventing the wheel' and is a Good Thing.
In this case you are talking about two different wheels. On two different types of transportation vehicle.
Zend is an MVC (model view controller) framework that allows you to build applications in php following that particular design pattern.
jQuery is a library that lets you do lot of stuff with the DOM and simplify javascript/DOM/ajax coding.
My answer is no :)
i think Following notes can help you::
Framework is collection of libraries which have software help, Many code libraries,scripting languages, Support programs etc..
But libraries is simple collection Of methods!!!
Not exactly. Zend Framework is framework and jQuery is library. Read here about difference between framework and library.
I'd say that jQuery is what CakePHP is for PHP and Zend Framework is what DOJO is for Javascript.
jQuery helps you with simple tasks, but is discutable for enterprise usage for the lack of systematic classes. It's more of the quick 'n dirty solution. It's faster in simple tasks, but for complex application it meets it's boundaries. It lacks comprehensive extensions loading mechanism AFAIK.
Something easy like CI (this means mandatory good, easy, up to date documentation). But also with some more features than CI.
Yii has lots of features, but it is also more complex (and it kind of forces you to have to use lots of it features). That means adding some functionality to your web-app takes three times as long because you have to figure out lots of new small functionalities of Yii.
It's kind of like the CI "gets out of your way" when it needs to, and Yii gets in your way, and if you don't do it its way, it breaks.
Features missing in CI that would be nice to have in this new "intermediate" PHP framework:
Code generation (crud).
Authentication.
Access control.
Layouts.
Widgets.
Easyer / automated pagination (like yii)
easy uri parameters
Where Yii causes me problems:
It's like for every small task there is some inbuilt functionality (this is good), but, YOU HAVE to use the inbuilt functionality, otherwise bad things happen. (CI gets out of your way, but does it too much, Yii helps a lot, but is butting in too much at times, and it forces you to sift through its documentation so that you discover these functions without which you are not able to accomplish a task that would take four time less, in CI, or in a non framework app).
Is there something in between ?
(ASP.NET MVC could be 'it', but I don't know the language, so the effort to learn it would be greater than learning Yii php framework really well, so I am looking for a PHP Framework)
I am a fan of CakePHP. I feel it has the specs you provided. If you want something more cutting edge you can take a look at Lithium
I have found some resources that kindof solve the problem, because they contain examples (Milan Babuškov's sugestion helped focus on "the solution").
Yii playground - examples
Yii cookbook - examples
Yii blog tutorial - more examples
PS. there is also google - I find solution (and examples) the fastest this way - ex: implement + pagination + yii
I've used both CI and Yii (on my own projects if that makes any difference). CI was my first introduction to MVC, and I found it easy going because it let me use any crappy structure and code. I wrote two full sites in CI (www.insolvencynews.com and www.thebigeat.com if you want to see complexity.)
I had a look at CakePHP but got NOWHERE.
Then I moved on to Yii and, like you, I found it pretty tough and rigid. But I then found that it was so powerful and extensible that I was so much more efficient. When I needed to add a few new features to the old CI sites, it was faster to rewrite the entire sites on Yii than to code up the extra features in CI.
I can't recommend a framework in the middle, but I can recommend sticking with Yii. When you say Yii gets in the way, can you give an example? Looking at DB stuff (in ascending order of dependence on Yii):
you can code using PHP's core MySQL functions.
$result = mysql_query($sql);
you can use Yii's DB abstraction layer.
Yii::app()->db->createCommand($sql)->queryAll();
You can use Yii's ActiveRecord:
Takeaway::model()->findAll();
you could try kohana (especially coming from ci)
You should check out the CI community, some of those extensions maybe have been written by someone else (I remember seeing Authentication and Components/Widgets somewhere)
Symfony is worth checking out. I personally don't like it much because they chose Prototype over jQuery for their ajax features, which is really annoying to use when you're used to jQuery.
Lithium might be good to check out too. However, it is php 5.3 only and you need to be really careful that this version of PHP is going to be supported on the server the site will be deployed on.
See this list for good comparisson:
http://en.wikipedia.org/wiki/Comparison_of_web_application_frameworks#PHP_2
From a personal point of view, I would go with symfony because of it's
rich features and
great integration with many other already bundeled components (Doctrine, Swift Mailer,..),
good (but at first complex) code generation that produces realy useable code to get you startet quickly,
powerfull use of templating (that will be the point you mention under "layouts)
many different, powerfull plug-ins, including Authentication & Access Control (it also has a plug-in to get jQuery support)
one of the best tutorials that I've seen with a framework
Downside is a
more complex structure,
IMO wired file structure,
a rather messy API documentaion compared to the tutorial
CodeIgniter is a nice framework if you don't want to create big apps but it lacks a great database integretaion and you already mentioned code generation.
im very good in Raw PHP, where the project at hand became too much to handle i decided to move to zend, with too too much complexity i finally moved to YII which really reduced the cost and overhead time for project development and most importantly for me is the simple integration of jquery, widget and advanced-OOP.
You could have a look at Qcodo / Qcubed.
They are both easy to pick up and offer code generation / ORM
Easy way to create forms in an mvc kind of way.
For what its worth, if you're looking for a PHP Framework that is like ASP.NET MVC then I think Prado is the closest thing you will find.
Who here is using WASP (http://wasp.sourceforge.net/content/) to in real world applications? What impressions do you have? Good? Bad? If you can provide any inputs, how good it is comparing with rails for example.
I'm really looking for MVC frameworks for PHP
Update: This comparation I found is good.
I downloaded it a while ago and tried it out, but as the documentation is pretty terrible at the moment (consisting of some auto-generated 'documentation' that was useless) I gave up pretty quickly. I think one of the most important things to have in a framework is clear, thorough documentation - if you have to spend time digging through the code of the framework to find out if a class you want exists, the point of using a framework is lost. WASP does not seem to be ready for production environments just yet, as even their website admits that its not ready for enterprise applications.
If you're looking for a PHP framework I would recommend CodeIgniter, which has excellent documentation and a helpful community, or Zend, which is pretty mature.
CakePHP is a great framework with great documentation. Symfony lost me with all the configuration, at the time I was new to both frameworks and CakePHP stood out as being the best for me and I was able to pick it up very quickly
Hey Victor, that comparison is pretty badly out of date. It was done about 1.5 years ago and, at least in the case of the Zend Framework that I use regularly,things have changed greatly since then. I'd say that comparison is so old as to be useless.
Check out symfony, too. Free software, top-notch documentation.
QCodo is great - amazing code generation, full MVC support. The strongest object-relational mapping I've seen; their scaffolding model is so much stronger than CakePHP and Zend... Plus, it's beautifully extensible with community controls. I've been using it for large projects for the last two years, it's great!
Have you tried CodeIgniter?
I tested CakePHP but it's too much a la Rails style and i didn't like it.
CodeIgniter gives you more freedom to do whatever you whant.