The steps to create an MVC web application - php

I've read many tutorials about MVC method ... I am now about to start an e-commerce application with PHP... So I'm confused about from where to start.(What's the best directory hierarchy ,the files, the templates etc)
Knowing that I will create admin pages(in a subdirectory with MVC), and website pages ... all I want is to know how to organize all this.
I've already created PHP websites (I am good in PHP and OOP). But not with MVC.
Thank you

As mentioned by #Daniel A. White, there already exists a lot of PHP MVC frameworks. Have a look at:
DooPHP (Personally love this one!)
CakePHP
Symfony (updated for version 2)
Zend
CodeIgniter

There are a number of different open source MVC frameworks for PHP such as CakePHP that should get you inspiration.

I'd start with a PHP framework like CodeIgniter because it's already packaged with a simple, effective and easy-to-use MVC structure that'll get you up to stratch with the logic necessary to start programming this type of web app. They also have a good user guide and support base - so help's never that far away if you run into trouble.

Related

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.

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.

PHP framework that can be included in other projects

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.

Object oriented php CMS or framework

I'm embarking on a very big exercise to build a CMS in php. It's actually my attempt to learn PHP in a fun (and hardcore) way coming from a Java background. Java is all object oriented so oop is in my blood, but I'm finding that OOP hasn't made it yet to PHP. Most PHP is still being written today the old way without the new concepts.
I'm trying to find an example PHP CMS that's written as object oriented. I hear Xoops is. Any others you know of? or any OOP libraries in general that you know of that could help me in a CMS project.
I would suggest symfony framework as it is well documented and functional framework that helped building many web applications.
http://www.symfony-project.org/
PHP5 is pretty OOP. Look for CMSes and frameworks that only work on PHP5. For example, Kohana
Concrete5 is a pretty complex OOP based CMS. Might be a harsh start but I've learned a lot by working with it.
again, +1 for symfony, but this is a large project and getting to know symfony will consume most of your time, yet if you want to dive in, its documentation is really great.
since you are trying to build your own CMS, get started with easy to grasp frameworks and build upon them. Don't waste your time on everything that has been already done. I recommend you Codeigniter MVC Framework http://codeigniter.com and for CMS, PyroCMS http://pyrocms.com which is built upon codeigniter is cool. Codeigniter is really easy to get along, and documentation is very neat and clean.
Further, if you like to start with a simple php framework, here's what Tyrehall has done, http://github.com/tylerhall/simple-php-framework . This project can act as a base for your CMS
No one seems to have mentioned Kohana the PHP 5 only framework.
Kohana has a pretty active and very helpful community to back it up (#kohana on freenode in particular).
edit: Upon closer inspection I see someone has already mentioned Kohana.
what you will notice is that what is more important to most cms (and framework) developers is MVC pattern implementation. Most MVC implementations in php do in fact use oop practices (some stricter than others)
+1 for symfony, and another I'd like to recommend is Kohana (built on CodeIgniter)
Also have a look at their forums, as both already have a cms or 10 built using these frameworks.
Using these frameworks brings you about 60% there, as a lot of the rudimentary tasks are taken care of.
edit
also remebered this one: fatfree framework it's quite lightweight: http://fatfree.sourceforge.net/
Have a look at Phundament 3.
Phundament 3 is an application foundation built upon a set if independent Yii modules and extensions such as user, rights, yiiext, gtc, ckeditor, jquery-file-upload, p3widgets and p3media.
The combination of p3widgets and p3media provides basic content management system (CMS) features, like dynamic widget creation and file management.
Combined in ckeditor, p3media acts as a ckfinder plugin which gives you the full power of HTML and media files for content creation via p3widgets.
It comes with a very minimalistic setup which integrates perfectly into an Yii web application skeletion and installs with one single command.
as some folks suggested here, you should start with Codeigniter because it's really easy to dive in. Its documentation is very well structured and easy to read. But I think Codeigniter seems to be very old now.
What I really recommend to you is Laravel. There's another Framework you should look into, that's FuelPHP. But for me, Laravel has absolutely changed to way I'm writing my PHP code. It is the best framework I've ever seen in my life. It's so elegant that you will instantly fall in love with.
If Laravel suits you, I recommend you to follow this online course by Jeffrey Way # Tutsplus.com. You will love it!
Good luck :)
Have you seen CakePHP?
http://cakephp.org/
Its a MVC framework for PHP. Its pretty robust and can be used in a fully object oriented manner.

ActiveScaffold for PHP

Ruby on Rails has a bunch of plugins which extend the normal scaffolding:
Lipsiadmin
Hobo
Streamlined
ActiveScaffold
Does the PHP community have anything similar? phpmyadmin is great, but it doesn't have any way to control the presentation of the data. You always get all of the data in its presentation format. These Rails frameworks are a little more user friendly.
Edit: My original question was not very clear. I'm not looking to compare PHP and Rails. I'm also not looking for an all purpose general framework. I'm looking for something just like the four pieces of software I listed above, but written in PHP. The admin software I listed above generates a crud interface for you based on your configuration. The configuration includes which tables you'd like to show, what operations you can do to the table, and who can see the information. The software does the rest, from writing the SQL to processing the request to generating the interface.
I would look at Zend, CakePHP, CodeIgniter or Kohana. See if they have an addon or plugin that can do it.
The problem with the four pieces of software you listed is that they extend Rails. When you say "PHP," there is nothing to extend in the same sense. (I really doubt you want a PHP module that does this.) You don't need a PHP addon, you need a [framework] addon.
Any of the frameworks I or Jonathan listed are similar to Rails. Kohana in particular has an addon module called Auto Modeler that may do what you need.
have you looked at pear: http://pear.php.net/
It's important to stress the difference between a language and a framework here. PHP is not itself a framework with modules. PHP is a language, like C or Python.
There are several website frameworks that have been written in PHP. The most popular would probably be Drupal though there are several that I've looked at over the last year that seem similarly capable:
CakePHP
CodeIgniter
Joomla!
Symfony
Zend
PhpMyAdmin is not a module or a framework. It is a separate, stand-alone web application for database administration, written in PHP. It won't be a component in any strategy for presentation of data on a website.
Symfony may be a "general framework", but it has scaffolding you can use as a complete application if your needs are simple. You define your model in a YML config file, and can then generate CRUD modules based on this model. The code generation is also customizable by editing other YML config files. All without writing any PHP code. But should the need arise, you have the option to extend the scaffolding with PHP and the complete framework.
See the Symfony docs on code generation.
A framework called ATK also claims a good code:functionality ratio ("An application in 10 lines of code").

Categories