Choosing between PHP frameworks and template systems [closed] - php

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 9 years ago.
Improve this question
I have a moderately simple assignment, to create a PHP/PDO site with login functionality and article retrieve/save/edit/search. No tags, nothing else.
Is this overkill to use some framework for this?
It it a good decision to use custom code + perhaps template system like Smarty for a simple site that will not grow too much?
Is there a software niche/best practices for small sites?
In a nutshell, I need logins/forms, but aren't frameworks like Zend or Cake too much for this?

I think that you can never go wrong by adding a framework to any size project. Anytime you can reuse something (and not reinvent the wheel) or leverage an existing code base to speed application development time, then do it.
Besides, you never know when your small to mid-size project suddenly grows to a large project. At least then you will have the pieces in place to grow your application and not have to start from scratch.

I'm a big fan of CodeIgniter, it would make setting up a simple website like this pretty painless. There is a fairly extensive stackoverflow answer about authentication libraries for CodeIgniter which would make login a breeze.
I would not suggest using a third party template library such as smarty. CodeIgniter has helper functions which can be used within 'views' which will allow you to do a lot of things quickly and painlessly, such as form creation.

I think using a framework is ideal for simple projects. They're quicker to set up and get going with. A framework may not be ideal if you need to fine tune how the site will run for reasons such as scalability or special requirements, or because you just don't like frameworks.

I'd suggest just using whatever parts of the Zend Framework you feel you need. Zend is very 'pick and choose' friendly.
That said, I recently used the ZF Application (MVC collection) for a two page site, just because it made things so easy. You don't need to have multiple controllers/models/view helpers to justify using a MVC framework.

Please don't user smarty. It's really unnecessary. PHP is it's own template language.
These posts on sitepoint tell the story well: #1, #2, #3

I've been using Kohana and I like it.
http://www.kohanaphp.com/
This guide got me started Kohana 101

For something that simple you can use a tiny framework like MicroMVC which comes with a equally small PDO based ActiveRecord-like database class.

Related

My Content Management System [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I intend to develop a Content Management System (CMS) like shown in the figure below;
Figure: Intended CMS design
Is it possible to completely develop it using PHP's standard library?
Do I need to use a PHP web framework? If so, why and what framework is ideal?
I hope to use MySQL as backend.
I hope to use below technologies as front end;
HTML5 and CSS3 - hard code by myself (Is there any framework or something make it easy? I heard something lesscss.org)
jQuery - to make HTML elements functional
Ajax - to avoid page refreshing
Bootstrap - to make my CMS responsive
Are there any technologies I do use, or any suggestions?
I prefer to improve my HTML, CSS, PHP and other technologies by learning and hard coding. So I hope not to use CMS like
joomla, WordPress, etc. Am I right?
Please note: I've already searched Google extensively before I put my questions here. But I am unable to confirm what I do next. Your comments are appreciated.
Your questions really look well researched and I think everybody with the intention of building a custom-made CMS has come to this point where they ask themselves these fundamental questions (in other words: good questions!). Now to some answers:
1) Yes it is possible.
2) Although building a CMS in pure, native, hard-coded PHP is possible, I wouldn't recommend it for production. You could do it, and you would largely profit from the experience, but there are many little problems (like Routing / User-Management / Authentication / Communicating with Database / Form-Building (like in your screenshot) / etc.) that are already solved by a good Framework.
Also as you are a beginner, you are naturally overwhelmed by the problems and decisions you have to solve/make. This is also a good point why a framework would be a good starter. Although some solutions are sometimes a little too opinionated, they still give you a good structure to start with and most of the times follow best practices of our industry.
Which framework is the most ideal for your project, you'll have to decide on your own, based on your requirements, but some common ones are:
Symfony (probably the most known and most used php-framework, but also very abstract / I would recommend this on a really big project, where you work in a team and you are aiming for flexible maintainability)
Laravel (excerpt from their website: An amazing ORM, painless routing, powerful queue library, and simple authentication give you the tools you need for modern, maintainable PHP.)
Silex (the little brother of Symfony, info from their website: Silex is a PHP microframework for PHP. It is built on the shoulders of Symfony2 and Pimple and also inspired by sinatra.)
FatFreeFramework (from their website: A powerful yet easy-to-use PHP micro-framework designed to help you build dynamic and robust web applications - fast!)
As I used Silex myself many times and also when I began with best-practice PHP, I recommend to start with it, if you decide to write your own CMS. I pretty fast did some Management-CMS similar to your screenshot with it (with their Form-Builder) and was happy with the result.
3) Again this is up to you. For the backend you will probably use MySQL anyway, if you just need a database. In the frontend using HTML5/CSS you could try jQuery and Bootstrap (and then here their less or sass implementation).
If you really don't have too much logic for your JavaScript, you could also try to just use native JS, without jQuery. This way you will also learn more about the language and have less vendor-dependencies the user has to download.
4) If you are really up to learning a lot, then yes, you should probably hand-code everything yourself. This way you also have total control of what code gets delivered to your user. That's a problem with most common CMS: they pollute your code through some other plugins or something and you quickly loose control over your output.
But if you need to be fast there are also CMS that address this issue by giving you total control over your output and giving you creative freedom, like MODX does.
In the end it is up to you and especially the needs of your project. If it's a simple website and you conveniently want to edit the content and also have some starter-help, then I recommend to use a CMS.
If you really want to learn about all this stuff and you have some special needs, then go on and code your custom-coded application. In any way: good luck! :)

Web development strach vs framework [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 years ago.
Improve this question
What is wrong if:
I dont use framework just use php pdo and in pages I check if user is loged in.
On frontend I use simple jquery ajax that work with JSON that I get from php pdo files and then create HTML with jquery...
I simple dont use relation in mysql...
So many developers say that my code is bad but that app builded with my code work exactly the same as code builded with laravel...
So why to use laravel or some framework when my code work great with php pdo and jquery...
Frameworks usually make things easier and faster to implement. Also, they are usually tested. So with a good framework you can save a lot of time. Also, you make the life of other developers easier, when you use common frameworks.
Furthermore, frameworks are usually maintained by a community and get updated frequently, so you have new features, without having to program them.
And some frameworks also allow plugins/extensions (usually 3rd party implementations), which you can use - again, without having to spend time implementing those.
And the last point I can think of, is that frameworks usually encourage some kind of application structure, so that you can extend your application easier in the future.
There is nothing wrong, when you write your own code, but it is just more work and takes more time and other developers might have a harder life.
Laravel Framework have the following rather than you're using, (Not in a well defined order)
Eloquent ORM
Query builder
Application logic
Reverse routing
MVC Approach
Packaging System
Restful controllers
Naming Conventions
Migrations
Composer Build
Automatic pagination
Form request and More..
Once you get started working with frameworks you don't ask this question.

When can I start using a Framework (Laravel)? [closed]

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 9 years ago.
Improve this question
I want to start by saying that I searched a lot for this exact question, but none of them satisfied my needs.
I program Php, MySQL, HTML, CSS and Javascript the 'old way', using just a text editor and building every website from scratch. I built websites from the most simple to an-almost e-commerce just by coding every piece of the application. The most advance thing I did was using some simple classes, like a database wrapper, singleton, and for the rest I always used functions.
Now, recently I signed up for a website where there are courses ( I won't say its name because I don't know if I'm allowed ) and I followed one about Laravel 3 ( I know currently its version is 4.x ), and I must admit I fell in love with it. I like it very much and I want to start using it but I'm afraid that doing so will 'dumb' me.
What I mean is that Laravel has a lot of helper functions, Eloquent structure and so on, so by using it I won't learn any more the pure Php because for everything you need there is already a built helper function.
To make a very simple example, if you want to join some tables you use Eloquent and within literally 3 second you accomplish this. If you want to log a user in, again you have an Auth class that does everything for you, even setting sessions.
This is my biggest fear, that I won't learn anything anymore because all you need is already provided, you don't have to think that much anymore.
On the other side, Laravel helps you a lot and it eases your work very much. As much as I want to start digging into it more I can't help but fear its downsides.
So, do you think I should wait and learn more traditional Php before dive into a Framework?
When is the right time to start using one?
Look at all the sites you built. Identify redundant elements. Extract them into classes and functions and build your own framework. This will allow you to build sites faster and build a library. Once you do that, there's no dumbing down. You can choose to use another or not... but you'll have yours too.
That's what I did. I have my own framework. And it ain't bad!
There are two types of developers:
users - they can use stuff and get by
actual developers - they can build stuff from scratch and give users tools
Choose which model fits your needs best.
1st category goes for quick results, are efficient and get the job done. These guys should use 3rd party frameworks and libraries.
2nd category are artists pushing themselves further with each new piece of code they build. They go for performance over turnaround time, code beauty and functionality vs. just functionality, etc... These guys feel offended by 3rd party frameworks and libraries and always roll their own. Because they can!
There's another catch. Some frameworks might have too much fat for your needs. Building more specialized solutions might actually yield way better performance than a one-size-fits-all framework. That's another perspective.
Bafta mai departe :)

php framework help [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 3 years ago.
Improve this question
Ok so before anyone states the fact that the php framework question has already been answered, note that I am asking questions specifically on which framework would be best given the requirements that I am providing. I am currently in the proccess of building a large project. I will be in the future working on several medium/large and a few small projects. I am an experienced php developer and fully know OOP inside and out and have a great knowledge of mysql database so learning a system is not a problem.
Now that is out of the way down to what I am actually looking for. I have currently been using a "framework" that is not so great and was provided to me for my projects. I would like to get rid of the "framework" and actually start using an actual framework. I was thinking of building my own framework but was considering (and really leaning towards) using an already preexisting framework. I have looked at a bunch of frameworks and even played with a few of them out there. Once I choose a framework I am going to want to keep using it and not have to switch 6 months down the road so before I choose I will be doing some thorough testing before making the final decision. I would like to get some input from some users as to which ones would fit my needs best.
In a framework I am looking for the following items:
Speed - because of being larger projects I will need to keep speed in mind. I can write efficient code but if the framework is slow it really wont matter now will it :)
Authentication - I would like to be able to use some built in authentication if possible through the framework. I dont necessarily need granular permissions based on users but more or less through groups (granular permissions is not a turn off just not a requirement).
Ajax - I like to use ajax in my applications so I would like some kind of ajax implementation in the framework and personally I prefer jquery. It doesnt necessarily need to have built in ajax features but a way to kill the page with the ajax output before anything is output for efficiency.
Forms - I have seen that alot of frameworks have built in features for managing forms but just thought I would mention it here to save myself the headache.
Administration - This is possibly one of the most required features that I really need. I need to be able to create a backend to manage the site. I dont want to have to hack something together to make this work.
Api - I will be in need of an api for accessing/modifying data that I will be allowing.
Database - Built in database methods. Doesnt necessarily need to do it automatically, just give me access to be able to retrieve/update the data that is need.
These are not neccessarily requirements but more or less nice features:
I would like to be able to encase all of my data that goes with a certain item into a "module" of a sort. So that I could easily copy it to another site and have it all ready to go.
An easy to navigate structure. I would like to be able to go into controllers and not see 50 files but instead see maybe 10 folders with the files encased in the folders so that it is better separated.
I cant really think of anything else at this time but if I think of anything else I will update the post. I would really like to get feedback from people who are using any frameworks out there. If you havent messed with a framework please do not recommend it as you have no experience with it and will not know if it would suit my needs. Any help is appreciated.
EDIT:
I just wanted to edit this post to clarify some stuff. In the requirements/features that I am looking for I do not necessarily need all of the features to be built into the framework. From some of the responses it seemed as if people were thinking that all of this stuff has to be pre-ready. I more or less am looking for a framework that supports all of the features that I am looking for that is easily accomplished with the components in the framework. For example the administration, it does not have to have a default administration area but allow for me to create an administration easily from the components that I will be adding to the site.
From my own experience ( CodeIgniter , Zend Framework ), but realy all major frameworks will allow you to do everithing you asked .
Speed - CodeIgniter is the fastest i worked with , this is not the strongest feature of ZF , in fact where i work we all got to the conclusion that ZF is slow .
Auth - Zend Framework handles auth better than what i saw in other frameworks
Ajax - All major Frameworks will allow you do disable the layout/view , Zend is slightly better here , as you can have special json views.
Forms - CodeIgniter framework handles forms easyer than ZF , however all frameworks should deal with this problem with ease . Symfony needs to be mentioned here with it's form generator .
Administration - Symfony just becouse it has a nice crud form generator based on the tables you're passing ( "admin generator" how they are advertising it ) , witch will speed development quite a bit .
???
Database - ZF handles databases nicer in my opionion , however i've heard good things about Symfony too . CodeIgniter here is not that strict witch is not a good thing in my opinion .
Modular App - Building modules in ZF is realy easy , and the feature that i like most is that a module structure looks like the whole app itself ( eg. the whole app is a module ... )
Easy to navigate structure - All of them once you are used to it , however i don't like the fact that CodeIgniter keeps all it's controllers in one place , when in ZF you can add modules and separate things from one and another .
Well, I worked with several PHP frameworks in the past and there aren't many good frameworks. You could risk a look at Zend Framework
ok
ok (but not enterprise level)
ok, but dojo
complicated
no, its a framework, not an application
ok, but not really a ERM
encapsulates PDO in an ugly way (bad implemented factory pattern)
ZF is developed by Zend itself, but I wasn't really happy with that too, because it has a lot of shortcomings (cruel DBAL, complicated form handling, supports dojo instead of jQuery) and if you are used to Java/JBOSS or .NET it just sucks (only mentioning this because you are planning a big project).
If you have some time until your project needs to be deployed and if you dont need to start immediately, you could also try FLOW3 (still alpha) which is developed by the TYPO3 Team. I've played a little bit with FLOW3 and can say that it is the only PHP FW which has at least a good architecture and some good ideas/paradigms (AOP e.g.).
If I understand you in the right way you would need something like a CMS for your backend. Maybe it would be a good idea to evaluate exiting CMS's and check out if you could extend them (use the CMS as framework (TYPO3 e.g.)).
You wont find a FW that matches exactly your needs, therefore you should consider choosing a CMS/FW and customize it in the way you need it. If the project is as big as I imagine there should be enough resources for such task.

PHP code design, structure, pattern ..? [closed]

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
I want to get some input from experienced PHP developers on how to structure code.
I feel my applications soon get "dirty" and unorganized.
Should I start coding in OO? Should I start using MVC? What about design patterns? What other options are there? How can I organize and structure my application code better (beyond proper indentation and naming)?
Links to resources are welcomed :)
If I decide to start coding using MVC? Should I use any frameworks or just hand code everything?
What is your suggestion.
Instead of worrying about creating something from scratch, I would start by using a framework and extend it with your own widgets. Zend Framework is excellent and has a massive community of support: http://framework.zend.com/
Otherwise, the best book so far I've found about PHP design is called 'Advanced PHP Programming' by George Schlossnagle. It explains patterns and design efficiently better than anywhere else I've seen.
As per comments below, I definitely don't mean to say that you should only learn a framework. It's never good to learn only a framework, but you can learn coding techniques through other peoples' code, like in frameworks/libraries/etc. Attack your learning through every source available (forums, books, code resources) and make an educated decision as to the approach you should be using when taking on a new project.
My suggestion : use the Symfony framework at least once, the tutorial will teach you most of the best practices you need to know, and let you organize your code in a good way.
Well for me JAVA is one of the best ways to really see how OOP is done. The way it's done in php is kind of lame. I've seen a couple of well structured maven based projects and I say "WOW" every time I see them again. You should start using the MVC model of coding as it'll make things easy for you to monitor - Controller = pages's logic, Model = page's (sql) data, Viewer = page's template.
Best you could see what I'm talking about at this site http://php-html.net/tutorials/model-view-controller-in-php/ .
Take it one step at a time. Download Smarty and get familiar with it. This should give you wonderful warm fuzzy feelings about separation of concerns, and give you some insights into other things to look into.
There is no silver bullet.
It doesn't matter how you start to plan, what matters is that you plan. Start with something basic like MVC and try to find reasons why your app shouldn't be made that way. If you can't find reasons, think about what frameworks might have features you are going to need.
If MVC is going to just add a lot of extra work. Such as if you are going to be doing a lot of complex AJAX or serious multi-level caching, or other reasons. Figure out what kind of system might save you time.
With heavy caching, sometimes basing the whole structure around a cache system can work. Tap into cached strings as templates and you can now alter pre-cached items. Useful for pages that are assembled on the fly iGoogle style.
The solution will come from the problem.
I would suggest you try to work with some popular framework. This way you can read clean code and form your style. 'Yii framework' is good enogh as for me. Offcourse, it will be useful to read about design patterns not only for your php skill, but for programming skill in general.

Categories