I am starting work on a personal project which should (hopefully) develop into a startup, the project will need to scale well and I would prefer to invest the time now in TDD.
I am a big Lithium fan, and I am aware that Lithium have their own built in test suite, but I can't find any solid documentation on it and I have never done any real TDD before.
Is there a better way for me to go? Or should I just stick in with Lithium and grind the learning process?
EDIT: Just to clarify. I am talking about PHP Frameworks, not testing frameworks.
If you think, that your project might actually grow into something large, you should write it without the use of framework. The problem with frameworks in general is that they are made with "everything and a kitchen sink" methodology.
You would be much better off, if you build it all from scratch (maybe borrowing some parts you like from Lithium) and use PHPUnit as your testing suite/framework.
Also, i would strongly recommend watching this lecture (and maybe some others from same series), for some general pointers.
Well, if you do plan on developing it in Lithium, then I would definitely stick with the integrated testing framework that's built into lithium.
Find it here:
http://li3.me/docs/manual/quality-code/testing.wiki
If you want to figure out how to integrate tdd into your normal development, I would recommend you pick up one of the .net mvc books by Steve Sanderson (since you seem to do a bit of .net already).
It should only take a few days of working though that book for you to get a solid understanding of how to integrate tdd into your development routine, since that book heavily emphasizes unit testing in development.
Good luck with your start up.
Have a look into Zend framework. It's one of the biggest and most comprehensive frameworks out there. Also it embraces MVC be default.
It also has a built in support for PHPUnit using Zend_Test.
Related
I'm about to develop a web app (PHP/MySQL). I prefer to use the MVC style when developing apps, but I've always struggled writing my own MVC framework in the past so I've started playing with CodeIgniter. After a couple of tutorials I better understand how to properly develop with a MVC framework and I'm totally comfortable using CodeIgniter to write my app.
The thing is I'm now wondering if its better to write my own MVC framework for this app or use CodeIgniter? My worries are due to the fact that I'm just getting this app written to serve as a prototype and will hand it off to more experienced developers down the road. I'm worried CodeIgniter has limitations that I'm unaware of yet and could hinder further development for me or the next developer(s). I'd imagine its easier to get around issues/limitations of a custom framework than it is of a 3rd party/ready made/stock framework.
Any insight?
There aren't any real limitations to CodeIgniter as most of the core can be extended. I have been using it for years and not found anything I couldn't use it for.
Kohana is a little more fun if you're into PHP5/OOP stuff but the lack of documentation will make learning it quickly rather difficult, especially if you are being paid to produce this.
Use CI, it will speed you up plenty.
I'd would go with CodeIgniter if you're familiar with it (and not writing your own framework from scratch), the app is a prototype, and it's getting handed off to more experienced developers down the line.
CodeIgniter isn't an obscure framework, it's pretty widely used and well documented. If your developers kick up a fuss, then they're probably aren't as experienced as they would like to think they are.
For a prototype I would say definitely use whatever you're familiar with, instead of making the project much bigger than it needs to be. Writing your own framework is a huge challenge, but it's also a really good learning experience. I've written my own suited to my own needs just so that I could learn the language "in the deep end" (and I keep adding to it whenever I use it... maybe someday, when I decide it's "fully featured", I'll release it into the wider world). But you should only do that if you've got the time, and plenty of room for everything to go wrong.
Well, the question is: can you do better than every other MVC PHP framework out there? Reinventing the wheel only costs more time and the focus off your application changes, because you have 2 seperate things to maintain.
I would stick with a proper MVC framework. We use Symfony exclusively for that use. It's a great framework with a lot of features borrowed from other frameworks and other programming languages. However, the list is endlessly for PHP framework. I recommend reading a bit about other frameworks and pick the one which is the most suitable for your needs. It saves you time in the end.
As a developer, I had to go through the same road.
Personally, I chose CodeIgniter as primary tool of my development, mainly because of community support and straightforward MVC. However, CodeIgniter was built by EllisLab, and they are not community driven. If you are looking for something that has more dynamic, community driven, open source MVC framework, I would suggest using Kohana.
Kohana has a good community, and they have some notable contributors. Check it out here
If you are thinking of choosing from different types of frameworks, I would suggest make a list of things you want out of a framework, and do your search based on that.
I'm building a site like SO using PHP as a personal project. I started out with writing flat PHP files (the kind with SQL queries mixed in with HTML). After doing a few pages I noticed that it was getting hard to maintain. So I started using an ORM (Propel). Then I got introduced to Symfony.
I started refactoring my code to fit in with Symfony's MVC pattern. To me, it seems that for a small project such as this Symfony actually makes things more complicated and I actually develop slower. Are frameworks more geared towards large applications designed by multiple teams? Or am I doing something wrong?
Any framework or new technology will have a learning curve during which you will seem to go slower. If you follow the MVC pattern and best practices for your framework, you will generally end up with cleaner, more maintainable code. There is some overhead to MVC and to getting things structured well. This overhead will payoff more for larger projects, projects that last longer (lifespan of the site as well as development time), and for projects with more developers. For small sites that will not be maintained, the overhead can be too large to be worthwhile.
If you're going to write PHP professionally, or you intend to write seriously, your time is well spent learning a popular framework or two.
Also, in no way is "a site like SO" a "small project."
It depends upon the framework and how much you wish to trade off ease of development in the future with speed of development in the present. The best way to get to the bottom of it is to try out a few frameworks and see what suits you best. A few random examples include:
Agavi
Kohana
Zend Framework
CakePHP
I have used all of the above and I personally found Agavi to be the best, although certainly not the quickest to work with. I was not so impressed with Cake as the rest, but again this is personal preference.
I don't know how "small" your project really is, but even though it takes time to learn a framework and design your project so that it follows the framework's philosophy it's usually worth it.
In my experience, when projects start to grow like your project apparently does (naïve PHP → factoring out the model → ...) you end up, in the best case, with code very similar to a simple framework. When you are using a framework on the other hand, the basic design of your project is usually really well thought-out, so even if you are not an experienced software architect (maybe you are?) you will get a good foundation for your project.
Also, you say that it is a personal project so I guess it's some kind of hobby or educational thing. Using a framework can be a nice way to learn about design patterns and best practices in web development.
Perhaps Symfony is not the best choice for you. I guess it's a matter of personal opinion in the end. Personally I like CakePHP when coding PHP and Django when coding in Python.
We are currently looking joining an open source PHP farmework project instead of continuing to work on our own PHP MVC code. Likely candidates are Yii and Solar, because they appeal to our own coding style, have tackled issues that we feel need tackling.
I realize there are plenty of PHP frameowrk related questions on SO already. However, I'm having a really hard time finding people that actually use one of these (esp. Solar) in a real world environment.
So, my question: did anyone work a real life project with one of these? How did it work out for you? What were the major issues?
I'm not looking for benchmarks or excitement about the theories behind each of these. It's clear that their creators of both frameworks did a tremendous job. What I want to know is:
did you use it?
did you like it?
pro's and cons based on real world use?
I use Solar daily for internal applications at work and personal projects at home. It is a top-notch, solid framework that I can highly recommend to anyone. It is in beta3, but stable should be coming along in the next couple of months.
A common criticism is the lack of documentation. I am happy to say that that is changing rapidly. New documentation is being written daily. In fact, two new chapters are already up.
A great way to get involved in Solar, or to get questions answered is to visit the IRC channel #solar-talk on freenode, or join the Solar Talk mailing list.
Visit the Solar website for all the info.
I can't comment on Solar or Yii because I've never used them. When I've given both a cursory look, they did not seem as stable as frameworks I've used before. I've developed with CakePHP for years and have run into the PHP 4 barrier with it, where continuing to develop for PHP 4 does not make sense any longer. Ultimately, it just costs more money.
If you are looking for a framework to build upon, I would recommend looking into the following:
Zend Framework
Lithium
All are very modular by nature (including Solar and Yii), with support for integrating excellent tools like the Doctrine ORM. Some assume Doctrine is your ORM of choice. Honestly, it should be.
ZF is decidedly PHP5 only, which I like. I also appreciate the modularity of it. I can create a base "project" and then add individual "apps" to it, each with their own models/views/controllers. You can also use its classes/features individually without the entire framework bootstrapping process. It is backed by Zend, and is very mature -- I'm assuming because so many trained eyes have used and improved it. The consequences of this are fantastic: just browse through the web site, follow the quick start and look at the available components in the reference guide and you'll see what I mean.
Lithium was forked off from CakePHP's Cake3 project, aiming for a framework with support only for PHP 5.3 and PHP 6. It is decidedly PHP 5.3 only, which means it has hitched its wagon to the newest stable PHP with the most features, such as anonymous functions, a native MySQL driver, and much more. Worth looking into if you are able to move your team to a PHP 5.3-only environment, especially if you have people who know the value of more modern programming techniques found in languages like Python or Ruby. It is a young framework, but has much of the same talent behind it that CakePHP has had, so that gives it a huge thumbs up in my book.
I've used Yii a bit now and have found that it's worked quite well for me. The main con against it is that it's still relatively new and most people haven't heard about it.
That said though, if you were to pick it up as your main framework, that would help it become better known and you might even consider helping Qiang with some development work.
Just when you are deciding, make sure you've had a look through the issues list to make sure that you are aware of what the current bugs are, and what the upcoming features/changes will be.
I can't comment at all on Solar.
I've worked for a handful of digital and new media design agencies in the North East of England for a couple of years now and have yet to come across an instance of the development team using a framework.
Most web design and development agencies these days favour creating their own framework or CMS; I guess it's a form of validation for them. They don't feel they're worth their salt unless they can develop their own systems and solutions from scratch. Hell, I'm the same and have build my own CMS!
The advantage of using an existing framework is that development time is reduced as commonly-used libraries and helpers are already pre-built and ready to be implemented. However, the use of a framework can easily become a con if the framework used isn't commonly known.
So for instance, if you use an obscure framework like Solar that not many developers are familiar with, any other developers working on your sites are going to have an additional learning curve, which in turn increases development time; the opposite of the desired effect.
Hope this helps you. Commonly-used PHP frameworks out there at the moment include CodeIgniter and CakePHP.
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 4 years ago.
Improve this question
Which one of this frameworks would you recommend to someone who knows the basics of PHP?
What are the advantages and disadvantages?
I wouldn't suggest any frameworks to someone who knows just the basics. Instead, I'd suggest to get a firm grip on OOP and the most common Design Patterns first, because that is what you will find in these frameworks. It also doesn't hurt to know your way around the various available PHP libs and extensions.
I think frameworks are a double edged sword for beginners. You may be able to do more in less time in many cases but in other cases (not a few) you will make mistakes because you do not understand the complexity of the framework code. I think you should be able to read a framework and understand its architecture if you want to use it.
That said it seems that the real cracks use Symfony. It might become or might already be the best, most versatile, most powerfull framework out there. But it definitely needs a lot of understanding of the principles of programming as well as web techonology and server technology in general.
Also very powerfull and much easier to start with is Zend Framework. It can definitely do much more for you than Kohana.
If you want a lightweight framework, Kohana is a good choice too. It has come a long way the last months and I think it is rapidly establishing itself as the new lightweight favourite.
So all in all, the three frameworks you mentioned are the three top frameworks on the PHP framework market at the moment and you won't make a mistake with any of them.
UPDATE: It is now 8 years later and Kohana is no longer maintained. Laravel would be my current recommendation for a relatively simple yet very powerful PHP framework.
Even though ZF is well established and well documented, I would suggest Kohana since it is quite a bit less complex. It is very easy to start tinkering with it by simply downloading or cloning the sample application from github.
Symphony is not for beginners. I disagree that frameworks in general are not for beginners. Starting with a blank file and no framework leaves all of the architectural design up to someone who has no idea what they are doing while starting with a lightweight framework like Kohana gives you a well-organised platform and documentation to hit the ground running. Learning OO without any examples to guide you is very difficult since you don't already know what good OO design looks like.
After downloading/cloning the Kohana sample app, hit the docs and you'll be writing well-designed OO code in no time.
For a beginner and using the three examples you gave I would say start with Kohana(or Code Igniter) for these reasons.
It's a lightweight framework which is a good starting point for full PHP development because it serves as a guide in how to organize a project in a language that doesn't have a lot of structure on it's own
Introduces basic MVC concepts.
Has basic features that will be useful in any PHP project e.g. caching, data filtering etc
I would then move on the Zend Framework if you plan or strive to work on larger projects for these reasons:
Kohana documentation is greatly lacking (it's manageable for a beginner because you end up poking around and see what makes a framework tick so that they don't see like this ominous holy code which is a plus; but in a major project with timelines it's annoying)
Kohana enforces certain conventions which is often inconvenient in major projects
Lacks mature features that are useful in "enterprise" development e.g. a decent unit testing system (there is rudimentary phpunit modules to use in Kohana and you can certainly use base PHPUnit but in contrast Zend Framework has extended PHPUnit functionality to better suite it's framework)
Better support. Zend framework has the Zend Company behind it as well as a huge community. This is a huge win for them because it permeates in everything about the framework e.g. configuration is thought out much better in Zend framework,more robust security featues, proper class autoloading based on PEAR namespacing, and it has a plethora of contributed components. Some of these benefits you can shrug of when starting but become invaluable when taking on large projects.
I've not used symfony but from what I can tell that also has some useful features once you get more versed in PHP (better ORM, better scaffolding etc). Synopsis: Kohana is a good start but I'd advise against roosting there if you plan to get into PHP beyond small sites.
In your case I would go with (in this order):
Kohana
Zend Framework
Since they are easier to pick up (specially for a beginner) than Symphony.
I always wondered why people say that not providing a unit test system is a major drawback in a framework. Well, testing you app is your responsibility and you should use the tools you're most comfortable with. Me, for instance, prefer SimpleTest and are bothered with framework that come bundled with and promote the use of their own testing system. Why learn another unit test system when SimpleTest is more than enough?
Notice that providing a unit test system and unit testing the framework is two completely different things. The framework should be unit tested, period. But for this task, the developers of the framework may use the tool they prefer most. They may even roll their own test framework (it seems that some people never learn and keep reinventing the wheel). However, (IMHO) the framework test should be kept separate from the framework itself. It shouldn't even be included on the framework tarball, but be kept as a separate package that interest only to developers of the framework.
Just my 2c.
There are several questions about PHP frameworks, but I'm curious as to which one(s) are used in the commercial world when developing web applications with PHP. At my first web-based job, they didn't have a framework for the PHP codebase. Is this common when dealing with PHP? If not, what frameworks to companies producing a product (either a site that provides a service of some kind or a web-based product that can be purchased) using PHP tend to use?
Is this common when dealing with PHP?
In my experience, unfortunately it is. This is of course a gross generalization, but people who tend to learn PHP as their first programming language don't learn the essentials of maintainable software development and often don't really know how to write good code. I think this is a failing of the PHP community, where historically most learning resources don't emphasize good practices (probably because the authors didn't know any better!). You can of course write good code with PHP, as long as you understand underlying programming principles.
Companies will often start out with a hap-hazzard code base of PHP scripts that get re-used and gradually extended from project to project (often without source control!). The companies that know what they're doing and take it seriously will evolve this into some kind of in-house framework, or I have often found they'll move onto something without the historical crapness of PHP, like Django or Ruby on Rails.
If you're just starting out, there are several decent MVC frameworks that will form a good base for all your developers to learn and use. In no particular order:
CakePHP
CodeIgniter
Zend Framework
There are of course others as well.
That said, as always it depends on the project. Sometimes a framework either won't make sense or will be overkill, othertimes you're better off using a pre-built product (like a CMS) and building extensions to it.
Most frameworks are strongly focused on the presentation layer. Now, "corporate" is of course a rather vague term, but I assume you mean for more typical IT tasks, such as accounting, CRM etc. For these tasks, the presentation layer is a much smaller part of the entire application. Not only does this make said frameworks less important - it actually disqualifies them somewhat, since you don't want the restrictions on your model layer, that they impose.
I think it gets more and more common to use a framework. A few years back most programmers developed their own framework. But the cost to train a new employee for such a framework gets higher and higher. Therefore many companies are moving now to well known frameworks.
I guess that Zend is currently the most used Framework in the corporate environment. One reason is that it does not give you any restrictions on the model layer.
I can not predict the future but I guess that Flow3 will be used in the future too. It is the new Framework behind Typo3. And many Typo3 developers (web designers) who need to write web applications will probably use Flow3 then.
In last two three places I've worked the company had their own (private, built in-house) framework.
According to a PHP Framework Popularity at Work survey by Sitepoint in 2015 (7554 survey participants) the five most used frameworks are
Laravel (22%)
Symfony2 (14%)
Nette (9%)
CodeIgniter (8%)
Yii 2 (7%)
Furthermore survey results indicate, that
5% use a company internal framework,
3% use no framework at all,
3% use a CMS for everything,
1% use a simple MVC framework.
There seem to be continent specific framework preferences: In America and Asia, Laravel seems to be the framework of choice (except for Russia: Yii 2), whereas in Europe you'll find more Symfony2.
(Be aware that this is just referenced from one source -- see links above.)
The only enterprise-level framework I can think is Zend Framework. CakePHP, Code Igniter and others are only focused on RAD development.
Having experience with CI , yiiframework and calephp (not much, really) my opinion is that CI is not flexible as ohter 2, so I do not recommend it on larger-scale projects.
Anyone who disagree, just can try a demo project with cakephp and Yii and he will see how things are easier with them as crud,form validation etc.
Of course all have their disadvantages :)
recently i talked with a CTO of a company, offering a e-lecture solution and we talked about PHP for a while ... we both agreed, it is not the best language for rock solid solutions, but he pointed out the symfony framework, they used just before moving to java ...
also, flow3 mentioned by raffael is quite powerful ... most interesting thing to me is, it brings AOP into PHP ...
greetz
back2dos
You may want to look at www.flow3.org, it's a pretty comprehensive approach to PHP application frameworking and is rapidly approaching its first mainstream Beta release.
I'm not sure if PHP has gone into the enterprise market in the US yet but when i worked in a corporate office the language what they use is Microsoft .NET.
PHP is yet to enter the corporate world IMO. It is popular with the hacker world and maybe micro and small software/web companies.