English 中文(简体)
Kohana PHP - Multiple apps with shared model
原标题:

I m using Kohana 3 to create a website that has two applications, an admin application and the actual site frontend. I have separated my folders to have the two applications separated, so the hierarchy looks as follows:

/applications
    /admin
        /classes
        /controller
        /...
    /site
        /classes
        /controller
        /....

My question is, how I need to go about creating a shared /model folder. Essentially, both the admin and site itself operates on the same data, so the database layer and business logic remains more or less the same. So to me, it makes sense to have a single model folder, sitting outside of the two application folders. Is it possible to achieve the following hierarchy:

/applications
    /model --> Where model sits in a neatly generic location, accessible to all applications
    /admin
        /classes
        /controller
        /...
    /site
        /classes
        /controller
        /....

Thanks in advance!

最佳回答

You can group all your shared models into a module. Basicaly, applications and system directories are just special modules.

问题回答

You could change your hierarchy while still keeping the admin and public section separated like so:

/application  
         /classes  
             /controller  
                 /admin  
                 /site  
             /model  
                 /admin  
                 /site  
                 model.php  
         helper.php  

This way both admin admin and site can use common helpers and models

I don t know if it s what Kohana normally does as I only have cursory knowledge of Kohana s folder heirarchy, but you could do this fairly simply with some symlinks on the file system, assuming you re on a unix/linux architechture.

http://en.wikipedia.org/wiki/Symbolic_link





相关问题
Brute-force/DoS prevention in PHP [closed]

I am trying to write a script to prevent brute-force login attempts in a website I m building. The logic goes something like this: User sends login information. Check if username and password is ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

定值美元

如何确认来自正确来源的数字。

Generating a drop down list of timezones with PHP

Most sites need some way to show the dates on the site in the users preferred timezone. Below are two lists that I found and then one method using the built in PHP DateTime class in PHP 5. I need ...

Text as watermarking in PHP

I want to create text as a watermark for an image. the water mark should have the following properties front: Impact color: white opacity: 31% Font style: regular, bold Bevel and Emboss size: 30 ...

How does php cast boolean variables?

How does php cast boolean variables? I was trying to save a boolean value to an array: $result["Users"]["is_login"] = true; but when I use debug the is_login value is blank. and when I do ...

热门标签