Welcome Guest, Not a member yet? Register   Sign In
[New] CodeIgniter + Shared Folder
#1

[eluser]Glazz[/eluser]
Hi =)

I was starting a new project in CodeIgniter and was in the need to use multiple application but one config directory,
off course CodeIgniter doesn't support this out of the box, so i started thinking on what i should do to achieve this, and i came up with a solution,
that works very good to me, and maybe work for you aswell.

Since i changed "lot" of code i will post a zip file containing a raw CodeIgniter project, i will include CodeIgniter 2.1.0 in this zip file.


With this you can have a shared folder, you can change the location of this folder and you can have:
- Global and individual application configuration
- Shared libraries, models and helpers that you can share on all your applications within that CodeIgniter installtion without the need to copy/paste
them all the time when you make changes.


Here is the zip file i talked about with all the structure and ready to use applications =)
http://dl.dropbox.com/u/19002464/Shared_..._2.1.0.rar


Both admin and site are application folders.

You access them http://localhost/admin/ or http://localhost/site/


Any suggestions, problems you may find please let me know so i can have a better system to myself too =)

Hope you like it =)
#2

[eluser]InsiteFX[/eluser]
I would setup a GitHub account because most users on here willnot download files like yours!
#3

[eluser]Glazz[/eluser]
InsiteFX thanks for the suggestion, but i don't know how to use github :c
#4

[eluser]InsiteFX[/eluser]
Phil has some nice articles on it!

Phil Sturgeon News
#5

[eluser]porquero[/eluser]
How is it solution compared by HMVC for CI?
#6

[eluser]Glazz[/eluser]
[quote author="porquero" date="1331046148"]How is it solution compared by HMVC for CI?[/quote]
This is not related to HMVC, i will work on this later to try to implemente the HMVC approach, but for now it doesn't do the HMVC job.

With this method you can have any number of applications with only one install of codeigniter but you can share models, helpers and libraries across all the applications without the need to copy them to the desired application directory.
#7

[eluser]porquero[/eluser]
[quote author="Glazz" date="1331046370"][quote author="porquero" date="1331046148"]How is it solution compared by HMVC for CI?[/quote]
This is not related to HMVC, i will work on this later to try to implemente the HMVC approach, but for now it doesn't do the HMVC job.

With this method you can have any number of applications with only one install of codeigniter but you can share models, helpers and libraries across all the applications without the need to copy them to the desired application directory.[/quote]

Well. I use hmvc in CI and I can separate modules and applications using only one CI installation.

For example:

/system
/application
/application/modules/module1
/application/modules/module2
/application/modules/app1
/application/modules/app2

The advantage of using hmvc is that you can call a controller from another or a view.

Examples:

Inside the controller
Code:
$module1 = $this->load->module('module1');
$module1->method($params, $...);

Or in a view:
Code:
modules::run('module/controller/method', $params, $...);

May be you can improve your solution with it.
I use wiredesignz / codeigniter-modular-extensions-hmvc.
#8

[eluser]Glazz[/eluser]
@porquero

Yes i'm aware of that structure, i've used it on the past, but i stopped using it for this reasons:

- If a customer wanted to use a module as a subdomain it was not that easy to explain to them how to set it up;

- Some customers wanted to change their backoffice/admin folder name, it is easy to change, but when i started web development using CodeIgniter i thought they are not wanting/going to change the admin folder name, and since i was "hard coding" the admin on the links like site_url('admin/some_controller') it was a mission impossible for them lolz;

- And if they wanted to move the folder elsewhere? They couldn't do it whithout asking me to change some lines in the code...



That's why i came up with this "solution", this way they can do whatever they want without breaking the code and it is easy to setup, IMHO i prefer this way.


I will try to have modules with this solution, but for now it does the work for what i need.
#9

[eluser]CroNiX[/eluser]
I use a variable to define the admin directory so it can easily be changed site-wide in one place. All admin controllers use that variable to generate their links. Then, just rename admin directory and update the variable to that new directory name.
#10

[eluser]porquero[/eluser]
@Glazz

I understand your point, and I think that each one use the architecture is more scalable according to needs.

Only one observation. ¿Can you try to use routing to "rename" apps?




Theme © iAndrew 2016 - Forum software by © MyBB