True HMVC/PAC in kohana PHP framework - php

I'm new to PHP and use of PHP frameworks. I chose Kohana PHP as my framework for a project I am working on (instead of alloy, also because it's the least complicated). Is there a way to implement MVC triad hierarchy in my Kohana project?
folder (root folder for mvc)
-|-subfolder
----models
----views
----controllers
-|-subfolder 2
----models
----views
----controllers
If anyone could help me in routing and forms for this kind of implementation, I would gladly appreciate it :)
note: I did browse through kohana's 3.3 docu, and I just don't get how to actually implement this

You can use one 'system' and 'modules' directory and different 'application' folder in one project. But there are some problems with routing(its really ugly) and code duplication (logs, configs etc.)

Related

Installed Zend Framework 2.x skeleton program in XAMPP, what's next?

I've just successfully installed the zend framework using XAMPP. The skeleton application works well. What I'm missing is which is the main file I can edit now for future programming?
Is it c:\xampp\apps\myapp\htdocs\public\index.php?
I noticed that when I edit it the homepage actually changes but I'm not 100% sure that it's the right file.
Thanks for the answers!
Cheers
Zend Framework 2 is an MVC framework, it means that models (the objects you will manipulate), the views (the pages that will be displayed) and the controllers (the logic and the links beetwen models and views) are separated. So you will have to edit several files for each actions, plus the glue and the configuration files.
If you don't know what to edit and are not sure of what you do, I strongly suggest you to read and follow the tutorial, wich will help you to learn Zend Framework 2, developping a small application: https://framework.zend.com/manual/2.4/en/user-guide/overview.html
c:\xampp\apps\myapp\htdocs\public\index.php is the file wich will iniialize and start the framework. You should not modify it.

Can I just copy/paste Laravel framework folder structure?

My website already have MVC architecture. I want to expand his capabilities by installing Laravel framework.
Can I just copy unzipped Laravel framework, so all folders and libraries are just copy/pasted. ?
I have VPS Ubuntu 12.04 and PHP 5.4.4
In which form your website has MVC architecture implemented ?
Is that through your plain PHP code or through some other framework ?
Laravel is implementing MVC architecture on its own way. In order to use that Laravel MVC capabilities, you will have to move all your logic inside Laravel.
UPDATE WITH SOME RESOURCES:
Official Laravel documentation
Laracasts - video lessons
Laravel IRC channel.
Good luck
The fact that you have used MVC does not mean that it will fit laravel's structure unfortunatelly. With different file structure, routing, controllers and models it wont work that way.
I dont know how advanced and expanded your page is, but you will probably re-write it laravel way.
Steps that you will need (assuming that you have some knowlege about laravel):
Prepare models for your existing database
Add routes for pages that you will need, create controllers for them using models
If you have used smarty templates, you can install smarty bundle for laravel, otherwise you will have re-write you templaets to blade (default laravel's templating engine)

Admin Routes (Nested Controllers or Bundles)

I'm studying the Laravel 3, 1 week ago, but didn't understand everything about the routes.
My main question is: how to create administrative routes?
In the video lessons from Jeffrey Way (Tuts Premium), I could understand two things about it:
Nested Controllers (/application/controllers/admin/user.php)
Bundles (/bundles/user.php) - He did not say much about it.
Anyway, I noticed 2 things (obvious):
On both sides, I can have a route / admin / whatever.
But what the correct way?
I'm really very confused.
Laravel bundles are for developing modular code that you can reuse from application to application in Laravel. The Bundle itself is very much the same as the 'application' directory you have as standard in a Laravel install, allowing you to create modular sub applications within your project. I highly recommend you avoid bundles for the moment entirely and focus on learning the core functionality of Laravel.
For your needs, place your routes within your routes.php file within the application directory and nest them to your hearts content. This will serve your purposes fine. If you're not building/using bundles, you don't need to use bundle routes.
When you're comfortable with Laravels routing and you've built one or two apps you may well have an idea for a bundle that will help you develop your apps faster in the future. This is the time to start learning about bundle routing as it's the only way to link your application logic with your bundle and provide it with a URL schema.
Hope that helps.
Neither way is really right or wrong, the beauty of Laravel is that there are so many ways to achieve the same thing so it's up to the developer to choose what works for them.
Personally I started by using nested controllers as they're much easier to get up and running. I would however recommend making the move to bundles. If you plan on sticking with Laravel (and you should) then it would make sense to build a bundle that includes the auth and components you use in each project already setup. That way you just need install the bundle and you're good to go.

Code reuse in PHP framework between multiple projects

This is my first question here. :)
I am working on a little php framework and started to think of ways to re-use the same code between multiple projects. Right now with this framework it is possible to make multiple application directories for different projects and use the same core - similar of what codeigniter 2 does.
The question about code reuse raised at work when I needed to make a website that is quite different from existing one, but would still use classes from it.
My first two ideas was either use some kind of a global "models" directory where to place files shared between multiple projects (and add option to framework to load them), or to add a possibility to load these "models" from other project(s).
I thought maybe somebody else have some better ideas and wanted to know other developer thoughts on the subject in general.
As an example this could be the current directory structure:
live/ - live site
config/
controllers/
helpers/
models/
public/
views/
admin/ - administration (same structure as "live/")
system/ - framework core
Well I don't think loading models or other classes directly from another project is a good idea. If two or more projects share the same classes, they should be located somewhere outside of both projects. This is the situation where the codeigniter packages comes in handy. It allows to have separate folder for all of your libraries, models etc. and load them in any codeigniter project very easily. Take a look at the official documentation for more details.

How should I extend the Zend Framework as a folder organisation point of view?

I am currently integrating the Zend Framework in my current project named VMM.
I decided to put the Zend Framework directory as a standalone project next to my VMM project in Eclipse.
I need to do some customization of the zend framework (For example I need to add Irradiance.php into Measure) and I would like to know where is the best place to put all my customizations.
I know that I need to follow the Zend Framework naming convention and the same directory structure.
So for example Irradiance.php contain the Mylib_Measure_Irradiance class.
I was thinking to put the Mylib folder into ZendFramework/library/Mylib next to the Zend folder.
Is it the regular way to extend and customize the Zend Framework?
If not, should I put the customizations inside my VMM project or as an other standalone project?
Thanks!
UPDATE
This question helped me but I still need some help...
I tend not to put my own library style files into the ZF folder mainly because when you come to upgrade ZF you'll have to copy them all over to the new ZF.
On my localhost I have something like this
my-project is the project I am working on and contains all the models, views, controllers,etc for that project
/htdocs/my-project/application
/htdocs/my-project/public
library is my own library files and mimics the ZF structure
/htdocs/library/Db/
/htdocs/library/Validate/
I then have my current ZF in /usr/lib/php/ZendFramework-x.xx.x this folder contains the latest ZF and can be changed easily without changing my projects or library code base.
Edit:
David's comments about 'pointers' reminded me, I always set up a sym link in /usr/lib/php/ called ZendLatest, this points to the latest copy of ZF, this means I don't have to keep changing my code or my php.ini.
There are many ressources out there:
http://www.slideshare.net/PHPBelgium/extending-zend-framework-presentation
http://cslai.coolsilon.com/2009/03/28/extending-zend-framework/

Categories