MVC and Crud Coldfusion 10 - model-view-controller

I am a big fan of ColdFusion just haven't used it for awhile. When I used to build sites, I would use the Illudium PU-36 Code Generator to create my MVC coding based on MYSQL. It worked great, but as I am getting back into ColdFusion it is not working with CF10. Being out of the ColdFusion world for a while, I am not sure how things are being done.
I liked the way the PU-36 generator would layout the basic structure(MVC) from the database and I could go from there - even though every change would take a little work. I still understood the starting structure and how to make the changes from there. It provided a good start.
Is the hibernate part of ColdFusion what I should be looking at.
I liked the the MVC basics based on a generator.

The PU-36 thing only deals with the data-abstraction layer as far as I can tell, and not really anything to do with MVC. The Hibernate wrapper in CF10 would replace all that for you these days.
As far as the MVC side of things go, there's a bunch of frameworks out there, and which is the most appropriate for you is a subjective thing, so you probably need to do your own investigations there. I've messed around with Coldbox a bit, but find it a bit heavy for my liking (it just does too much). However other people swear by it. I have had a superficial look at Framework One, which is much lighter and more how I'd want a framework to be (mostly out of the way). And there are a bunch of others, which Google will help you investigate.

Related

Joomla versus CodeIgniter/YII

A partner has a website that needs to be rebuild from scratch as it simply can't cope with the large number of visitors (currently build using SilverStripe). The site should be able to deal with 5 million or more members using 20+ languages.
We were considering using CodeIgniter or YII because from research both appear to be excellent performers. However several people advised that we should consider the latest version of Joomla for this. For small websites we are happy to use Joomla but for a heavy load website our feeling says that we have to stay away from that. We are however not able to find any comparison between both from a performance point of view but we do require good arguments why Joomla would or would not at all be a good candidate for this. One comparison can be found here: http://vschart.com/compare/yii/vs/joomla/vs/codeigniter however this doens't tell me what to expect when the number of visitors is really high.
Can some advise how Joomla compares to CodeIngitor or YII considering that the site will receive a very high number of vistors and will use a 20+ languages (for silverstripe we build a translator module as the build in CMS was not usefull when using so many translators).
When you're dealing with a site of that scale, it's probably best not to shift to Joomla. Joomla can handle a fair bit, but I'd suggest that it would be far easier to have a Joomla site that large when the site has been adapting as the traffic increases.
Part of what makes your question hard to answer is that we don't know much about what your current site does.
Is it mainly a CMS? If so, Drupal may be a decent fit for you.
Is it a custom web application? It sounds like it could be, based on the number of translations you're handling.
Is it somewhere in-between? This could also be what you're dealing with.
If you're looking at either of the bottom two options, yes, shifting away from SilverStripe (but not to Joomla) sounds like it might be a good thing.
Given the volume of traffic you're dealing with, it sounds like you probably already have a revenue stream and a development team. In that case, it might be worth having a few of your developers play with CodeIgniter and Yii and see what they think.
I wrote up a detailed answer to a question about what type of framework to choose a while ago, which you can look over here:
https://stackoverflow.com/questions/10095906/yii-or-zend-or-other-frameworks-under-the-following-requirements/10115678#10115678
I'm a Yii fan, having checked out a bunch of other frameworks. Regardless of which framework you use, I'd like to offer one piece of advice that I've found key on all projects I've worked on.
You want to work with objects, not data arrays
The reason for the above is that your models (and the objects they produce) can end up having your business logic built into them. Doing this makes life far, far easier in the long run. A great book on the subject, aimed at manager's and quite high-level (there is no code, although there might be a few lines of psuedo-code), is Object Technology: A Manager's Guide. I'd highly recommend it.
Framework thoughts
CakePHP
I started dabbling with CakePHP until I found out it didn't hand back objects (just arrays), at which point I ran screaming.
CodeIgniter
Looking at what CodeIgniter has for database model support, I think you would quickly hit its limitations with a site of your size, so would recommend against it. And having EllisLabs deciding to leave CodeIgniter behind (see their website for more details) is not a good sign. The signs say stay away.
Of the PHP frameworks out there, these are the ones I hear the most things about:
Symfony 2
Yii (disclosure: I work with this one daily)
Laravel
Symfony
From what I can see of it, has been a huge stimulus to the PHP community and many best practices have come out of that community. Unit testing, Composer, pushes for PSR-1/2, the ideal of modularity of code (some of their core code is ending up in Drupal 8) are all great things that have spurred the PHP community into writing code that's better than spaghetti code. With that said, it feels kind of heavy and enterprise-y and looked to have a pretty heavy learning curve.
Yii
When I was looking for a framework, I had a lot of legacy code that needed migration. Yii's way of handling things, although opinionated at times, has done a lot for me as far as exposing me to good practices that are used heavily on the web. Highly recommended as well.
Laravel
When I was looking for a framework (2+ years ago), Laravel didn't exist. It's apparently quite slick and cutting edge (haven't looked at it yet, I've been busy landing new work regularly in the Yii world), but I am interested in dabbling with it. That said, here's a thoughtful article about Laravel and couple of considerations that I've wondered about.
The main developer, Taylor Ortwell, seemed to be a dominant force. That's a great thing while he's making money doing this and enjoying it. Not sure what would happen to the framework if he decided to do something else.
The speed of development on the framework is an awesome thing and means that all sorts of creative juices are flowing. It's a great place to go look at cool new things. That said, you're going to want your developers to be able to easily find information about the framework they're working with, which in 3-6 months may be severely out of date in the Laravel community. The Ruby on Rails community has the same type of good/bad problem when I've looked around over there; there is so much information about the new stuff that sometimes it's hard to find information about the version of the framework you're dealing with.
That said, there are lots of cool choices out there :-) I should probably wrap up, as this has gone on far longer than I'd intended. Let us know what you end up deciding and how it ends up going.
How big is the site really? Bigger than joomla.org?
Are you talking about big in terms of the amount of content in the database or in terms of the number of visitors.
Joomla really does not have problems with scale unless you are on an older version of MySQL in which case it slows down.
It depends on what kind of application you want.
If you want a CMS, Joomla is the way to go. Because this is what it was build for.
If you are about to create a real "custom" application Yii/Codeigniter is the way to go. (This is what yii was build for)
Regarding performance, from my expericnece Yii is a lot faster, because it comes with way less overhead. You can build the application just as you need it.
Well it's like compare green and salty. Really joomla is CMS, and Yii and CI are frameworks. If you considering make highload on joomla - it's not your job.
If you have high frontend load - maybe watch on js frameworks? Yii+backbone.js or ext.js for frontend is awesome, since you'll move alot to clientside.
CI is dead. I honestly like it, but its dead already. No extensions, no namespaces in future, nothing.
I can say + of Yii:
*faster then CI;
*have great documentation and wiki articles;
*have great and active community and developers;
What else i can add? Active record is good for small databases, but not usable for highloads. Also as i said on yii you can easily make js framework+yii composition. Yii have good caching system. Long time support of stable versions.
I personally manage highload now, but its more backend/api/database. 150+ thousands database records daily, 300+ thousands requests to api, 50 milions records data table. It works like a clock for more then 2 months already.
Choose what you like, or write on native php if its really big system - best choice from practice.
Joomla is an award-winning content management system (CMS), which
enables you to build Web sites and powerful online applications. Many
aspects, including its ease-of-use and extensibility, have made Joomla
the most popular Web site software available. Best of all, Joomla is
an open source solution that is freely available to everyone.
CodeIgniter is an Application Development Framework - a toolkit - for
people who build web sites using PHP. Its goal is to enable you to
develop projects much faster than you could if you were writing code
from scratch, by providing a rich set of libraries for commonly needed
tasks, as well as a simple interface and logical structure to access
these libraries. CodeIgniter lets you creatively focus on your project
by minimizing the amount of code needed for a given task.
Yii is a free, open-source Web application development framework
written in PHP5 that promotes clean, DRY design and encourages rapid
development. It works to streamline your application development and
helps to ensure an extremely efficient, extensible, and maintainable
end product.
Joomla can't compare with CodeIgniter / Yii. But, If you need any CMS for your project, you can use Joomla (or maybe Wordpress). If you want to create any web application, then you need to decide for any PHP Framework. I use CodeIgniter for years, and I like it. They have a huge community, and the best user guide. Yii also has a great community and a lot of features. So, you can decide depending on you demand.

MVC3...more abstraction?

I'm learning MVC3 (my first touch with MVC) and going through tutorials in the book Pro ASP.NET MVC 3 Framework, 3rd edition.
As I go through the tutorials I am started to get a little scared of all the automagic stuff going on. What I hated about ASP.NET webforms was all the automagic, smoke and mirrors.
I like dealing with the nuts and bolts more often than not because I don't like the whole "And then you just trust the system to do it's thing, trust us, it will work", because even though it does work most of the time, whenever you go out of bounds or want to do something more complicated, the obfuscation of the smoke and mirrors causes a lot of headaches (ok this paragraph was a bit of a rant, though necessary for my point).
Before I get too far down this road...is MVC3 just a more sophisticated, smoke and mirrors, obfuscating framework like ASP.NET webforms, or is it going to allow me to peek under the hood and get into the details more easily than asp.net? Is this worth continuing?
SIDE NOTE: PLEASE, if you don't like this question, don't vote it down. Help me make it better so it can benefit the community. Thank you! :-)
I've been working with this framework for one year and a half, and all the "magic" stuff has never got in my way, actually most of the time it has helped me, and when it hasn't then I just have coded around it.
I mean you can code the way you want. You don't like the "Routing" feature? you can change it as easy as going to web.config and rewrite it.
You don't like the binding magic for your parameters? Then get them manually HttpContext.Request.Params["yourParameter"].
You don't want to use EF?, ok use whatever ORM you want or just create your own ORM and use it.
You don't like the MVC pattern? then write all your code inside your views (I think I went too far).
I mean it's even open source, do you want your own magic inside the framework? you can do it.
In my very personal opinion, it is worth continuing.

XML and YML in context of Symfony2 and SpringMVC

I'm on my way of getting a decent programmer but it seems that the things there are to learn are countless. I know that there's never a certain answer when one ask which is better, but I'll try to make my question more specific hoping for a more certain answer.
I'm using/working with PHP for a year now. Starting from the most simple examples, now I'm using CodeIgniter and various libraries/frameworks for the frontend and I feel like I need to make a step ahead, which in my case is learning another PHP framework - Symfony2 and also, because I'm getting my masters degree on "Software technologies" now and there I intensively use Java, I want to try and start learning both - Symfony2 and Spring. Among the many questions how to accomplish that without ending with just a lost time, the usage of XML, YML is something where I see an option for getting an edge in my work.
Java is heavily XML, and as far as I know, there's no escaping from XML in Java. But in Symfony2 one have a choice and it's very tempting to use XML there so I won't need to learn one more thing among all others but most of the examples I see for Symfony2 use YML and I'm not very sure that skipping yml and trying to stick strictly to XML won't turns back on me.
I'm not experienced neither in Spring or Symfony so if it was you learning both of them at a time how would you approach? Using XML for both, or using YML for Symfony2?
I'm making my money as a Symfony developer, while developing my personal project in Spring MVC, so, since I've seen the both worlds, I think I have something to share on this topic.
I'm developing in PHP for like 7 years, and I know Java as a language for like 5 years, but I'm developing my first “real” Java project just for a month or two. Eventually, I want to ditch PHP for good and switch to Java and/or other JVM languages like Scala.
What's the reasoning for this? Well, don't get me wrong, Symfony2 is a great framework and I really love it. I believe it's the best PHP framework out there. But... it's still PHP, you know. No matter how great a PHP framework is, I just can't stand PHP as a language for too long. What's so wrong with PHP, you ask? There is a great article explaining exactly what I've been feeling about it for a long time (at least read the analogy section).
And since I prefer static binding and strong typing, I'm more comfortable with Java for this reason too. It's just so great what a Java IDE does compared to what the best PHP IDE does. I think I'm using the best IDEs for these languages out there — IDEA (with the PHP plugin) or PhpStorm — and Java support is just so much better it makes me want to dance.
I'm not saying that Java is the greatest language of all, but it's a huge improvement over PHP. I think Scala is very promising, but since its infrastucture/ecosystem is not mature enough for me — a pragmatic who likes to get the end-user projects done, compared to guys hacking the languages themselves and developing frameworks — I'm staying with Java for now.
So, for me it boils down to the language, community and ecosystem. While the PHP community has some great developers and I enjoy having conversations with them on IRC or other places, the Java community has much, much more great developers developing much, much more great stuff for the much, much bigger Java ecosystem.
Apart from those 3 things, I could add that Symfony is much easier to learn — its book and cookbook are great and really to the point, while I have to hunt down a lot of information about Spring in numerous books, blogs and its vast documentation.
Speaking of YML and XML, you can do a Symfony project in XML only, and you can do a Spring project completely or almost completely without XML — especially since version 3.1. I use YML in my Symfony projects but XML for bundles I share.
And since Symfony DIC and security are based on Spring and Spring Security, and Doctrine is based on JPA, learning idioms of one of these frameworks, you learn a lot about the other one. What I'm really missing is a Twig analog in the Spring MVC world — JSP gets the job done, but it's not that great. I know there are other view technologies Spring MVC integrates with, but to me it seems like JSP is the most endorsed one.

PHP Frameworks: Help Me Understand Common Statements

I've been reading up on several PHP frameworks, and reduced my candidates to CodeIgniter and Symfony (I know there are many more). Strongly leaning towards CodeIgniter, but have not 100% decided quite yet.
I'm not looking for a general "CodeIgniter vs Symfony" discussion.
One thing keeps coming up in comparisons: people say Symfony is for "advanced" coders and "bigger" sites; CodeIgniter is for "beginner" coders and "smaller" sites. But I have yet to see any technical proof of this. Everything I'm seeing about CodeIgniter feels right.
Can anyone explain structurally and technically where people are basing these statements on?
I want to understand all I can. Once I make a decision, I want to focus my attention on one framework.
Thanks,
Matthew
The biggest technical difference between CodeIgniter and Symfony (ver 1 and 2) is that Symfony is much easier to extend. This is especially true with Symfony2; you can replace entire parts of the framework as you see fit with custom code, or code from other libraries. You can even take any number of core components from Symfony2, and build your own framework on top of it. But, it's important to note that because Symfony is so 'advanced', it has a higher learning curve.
Here's how I see it: CodeIgniter is great when you have a small(ish) project that falls in the category of problems CodeIgniter is meant to solve. But when you want to do something your way, not CodeIgniter's way, you're going to have to fight the framework, which is never fun.
On the other hand if you're working on a Symfony2 project and want to do something your way, you can. It won't necessarily be quick, but it is possible. To me, that's the most important thing - you need to be able to make the framework do what you want it to do.
If you have time, read through the Symfony docs and cookbook - they should give you an idea of what Symfony is capable of and how to customize and extend it.
Everything I'm seeing about CodeIgniter feels right.
Then go with CodeIgniter. The most important thing is that you're comfortable with the framework/toolset. If you complete a project and find that it's lacking in features, you can always check out other frameworks.
I would recommend starting without a framework. If you have been programming awhile and are comfortable with concepts like MVC and why you might implement your code in this pattern, then frameworks start to make more sense.
Frameworks are good for larger projects where there are many programmers and you need a consistent method of building application layers, like MVC. The framework will likely provide some mechanism for object management and a consistent way for you to build application events (controller) and to separate the view logic from the model logic.
My PHP apps have been smaller, so I have not used any frameworks. When I used to code in Coldfusion, on larger apps, I used MachII, Model-glue, Fusebox and ColdBox. Each was good at something, each promoted consistency, but each had a lot of overhead and often times felt like it was in the way. I saw some developers get stuck because of the framework.
I did not start using any CF frameworks until I had build smaller apps without one.
If you like CodeIgniter better, for whatever your reasons, go with it.
CodeIgniter, because of the gentle learning curve and the great documentation. Give other frameworks a go if you ever feel you outgrow CI, which you may never do.

Modifying Code Igniter

I am looking into developing a commercial application using PHP. Since I have experience in CodeIgniter and it has been working well for me, I decided to use it. Now, if ever my application comes to a point that it needs to grow and have to have custom modifications in the platform, is it possible to modify the CodeIgniter source code to the point that it's far from the original?
I'd strongly recommend not modifying the source code as this is the back bone of the application will make updating to futures releases of codeigniter impossible.
Instead you should be creating your own classes/libraries that extend the core bases. This is best practice.
The codeigniter users guide has some fantastic information regarding this, http://codeigniter.com/user_guide/general/creating_libraries.html
Good luck.
Don't modify it, extend it. Ellislab is good about releasing bug fixes and patches, and the last thing you want is to have to re-engineer all the updates into your new hybrid everytime they release updated source code. Plus, different features and bug fixes are released at different paces for the core and reactor, so unless you plan to lock your framework in at the current version, extending is the way to go.
The good news is CI is built for and encourages extensions of the source. The system folder and the application folder separation are a clear indication of how you should segregate your enhancements from the base libraries.
CodeIgniter is written in PHP. You can completely rewrite the framework anyway you like. So the answer is "yes".
There are many big websites that were written in a different language or build on a framework when they started and have been rewritten many times since. I think a lot of developers (mostly freelancers) are over-thinking when starting out. When I start a project, then I try to get it done and get it out in the web asap. If a website starts taking of - and most of the times start making you money - then you can always take the time to rewrite it.
I think it is a lot more important to spend time when you plan and design your database and tables. I think it is a lot harder to redo parts of your database later on then it is to rewrite the code that uses the data.
Just my 2 cents.
If you have used CI, then you should know that being a PHP framework that all of the source-code is there in the download, furthermore opening the system and application folders and looking through there will tell you a lot. Yes all of the source is there in plain English (plain programming English) and not only is it in plain English but has been extensively documented inside and out (literally that is in the source and in the user-guide). CI gained initial fame from that simple fact, that all code is extensively and meticulously documented.
Beyond all that, the question itself raises concerns that maybe you should study CI a bit further before writing commercial applications using it. Ci is a powerful and very easy to use PHP framework, but it is not a WYSIWYG. In my opinion, a coder should know his tools inside and out in order to be able to create a solid secure and trusted application. The first measure of which is to read the user manual, you should know at the very least everything in it, and since there are 12 sections in it that cover everything from extending CI libraries to creating your own libraries, and everything in between I would say you need to spend a little more time with it.
I want to say though, I am not being rude or trying to shame you in any way I am simply saying that you should learn the framework a bit more before venturing into a commercial application using it.
In the early days of PHP people realized how amazingly easy it was to use and how fast you could write an application with it. At the time the major options where very difficult for new and hobby programmers to use or involved expensive software to run, PHP was free, easy to learn and most of all ran on a free OS. It also took hardly any setup to get going, you could download PHP and essentially be programming in minutes. All of these factors lead to the almost destruction of the language.
Entry level programmers were destroying it with bits of code taken from other applications, never knowing (or caring) what the code actually did beyond the simple fact that it did what they wanted at the time, never considering or even investigating if the code might be harmful. Because of this practice PHP applications that had grown to Goliath sized websites, taking thousands of hits an hour were:
beginning to crash
being hacked to reveal sensitive customer/client data
generally crumbling all around the web
All because since the language was so easy to use that people had taken advantage of it and failed to take time to learn it. PHP was becoming a joke to other professional programmers and wasn't even thought of as a viable application language by many who had dubbed it "the copy and paste" language.
So my advice to you, please take the time to know your tools inside and out, what makes them tick, if they have any gotchas and where they are vulnerable. I understand that in order to learn a language to a professional level you have to build with it so I suggest that you take it slow with CI stick to the core for now. Trust me when I say that even in its purest form CI is an amazing and powerful tool that in the right hands can create awesome powerful web application, but in the uneducated/inexperienced hands it can create havoc and destruction.
So (stepping off of the soap box) I simply ask that if you are serious about creating commercial applications period that you take your time and learn your tools/language become as close to an expert on them as possible. I gurentee that if you do that you will always have work when you need it and you will spend less hours beating your head against the table or worse explaining to a client why their site is down.
I truly wish you good luck, just slow down and learn your trade and you will do just fine.
Yes, Codeigniter is an open source framework. However, I would advise against modifying the core of Codeigniter, as most files can be extended and rewritten safely without modifying the core files which will cause you headaches if you ever decide to update.
To extend a core class by default you would do this in Codeigniter. We'll extended the parser class for this example, but this applies to all classes pretty much. This link in the comprehensive user guide will give you all the information you need to extended and overload methods inside of a Codeigniter core class: http://codeigniter.com/user_guide/general/core_classes.html

Resources