Configure multiple websites using one core (CakePHP) - php

I have a system runing on my webserver in /my_system folder
I need to duplicate it, for 2 new websites. They'll use the SAME system, but different databases.
I need to place them in specific folders.
Like:
/my_system/client_1
/my_system/client_2
/my_system/client_3
Then I can use url prefix to guess which client I want and which database I need.
Tthe configuration was very easy, by using .htaccess and just editing some lines in database.php
But now I'm having a problem:
When I try to access /my_system/client_1/Page/1, instead of search in Pages controller, Cake tries to search the client_1 controller, which doesn't exists.
I've tried to add the client_1, client_2, client_3 to routes prefix (Configure::write('Routing.prefixes', array('client_1', 'client_2'));), but didn't worked.
So, what's the best way to work with it?
BY only using Rewrite in htaccess I can deal with it?
Obs.:
If I try to access /my_system/Page/1 I can access it normally, the only thing I need to do is work with the mentioned prefixes.
Thanks.

You'd deal with this using CakePHP's routes.
They wouldn't be prefixes because you already have a prefix of 'my_system'.

Take a look at this great yet simple article
CAKEPHP 3 – DEFINING THE CORE OUTSIDE WEBROOT
You might be able to do the same with version 2.x

Related

Different folder for views - Laravel 5.4

I'm trying to make a reusable Dashboard for my apps, so I decided to put everything in a folder like app/Dashboard. I've managed to have routes, controller, middlewares, etc. But, now I'd like to have views also in that folder. I added the path in config/view.php, the problem with that is that if I have two views with the same name in app/Dashboard/Views and in the default resources/views, of course the view in the default path would be loaded.
Do you have a better idea? Can I do something like return view('dashboard:login') in my controller using only the Laravel standard tools?
Look at this part of the documentation https://laravel.com/docs/5.5/packages#views. You are almost right, but you need to use two colons
return view('dashboard::login');

Change templates/views location in Symfony2

I will be working on project that has different theme for each domain (same application will be serving multiple domains).
I need to change location of templates completely outside the application folder, possible on another volume
I need to make it work with multiple domains with multiple themes - i guess theres cache problem
S how to do this stuff with Symfony2 and twig?
EDIT: I will try to ask this: What or where do I need to rewrite to get custom logic on locating specific templates that symfony uses to render pages.
I can't say if first point of your question is a bad practice (and don't know even if it possible, but I would say yes).
However, what I would do is some kind of "manager" that will takes responsibility for choosing what kind of template render, based onto your own logic. Some kind of "intermediate level" between actions and views.
You could create it as a service and use everywhere, without have need to instantiate it every time.
It could read a file for configuration or, even (but less springy), use a class-internal configuration.
Algorithm could be something like this:
Take into account your request
"Eat" data and "spit out" the correct template (name)
Pass template (name) to your view
Extend (dinamically) the template given by your manager
Please, don't ask me some code because it could result in some hundred lines :)

What's The Proper Way To Set The Public HTML Folder Using Yii Boilerplate?

I can't find the documentation specifying how to set the public html directory. I am trying to keep all other files and folders in the site root. Since there is a frontend and backend public html folder, I don't see how this is possible.
My Site:
/site/perl/
/site/www/ <-How do you get just the 2 public folders here?
/site/.ssh
Yii Boilerplate:
runpostdeploy
yiic
/backend/
- /config
- /www/index.php
/frontend/
- /config
- /www/index.php
/common/
/console/
/tests/
Is the whole boilerplate project supposed to reside in the sites public html folder? I thought it was bad practice to do this.
*** U P D A T E ***
Spent most the day trying to figure out this problem. The closest thing I was able to find, was a comment on one of the Yii Framwork forum posts. For now, I'm running Boilerplate with subdomains like they recommend in this comment.
http://www.yiiframework.com/wiki/155/the-directory-structure-of-the-yii-project-site/#c9444
I'm not sure if this is the correct way. But it works.
You should set your site public director to frontend/www/. The idea behind Yii Boilerplate backend/www is to have separate domain for admin options (if needed), instead of having separate module. This way you'd be able to easily have separate CWebUser, Yii::app() etc. By the docs:
backend: the backend application which will be mainly used by site administrators to manage the whole system (avoiding admin modules at frontend application to avoid confusion)
I believe if you have two application, then you need two address.
You can do with sub-dir like this:
www.site-name.com -> ../frontend/www/index.php
www.site-name.com/admin -> ../backend/www/index.php
Or you can use subdomain like this:
www.site-name.com -> ../frontend/www/index.php
admin.site-name.com -> ../backend/www/index.php
It's like Wordpress, if you need enter admin page, you access through address www.site-name.com/wp-admin
But, be sure you don't use the 'admin' path in your frontend if you use this alias to backend.
Spent most the day trying to figure out this problem. The closest thing I was able to find, was a comment on one of the Yii Framwork forum posts. For now, I'm running Boilerplate with subdomains like they recommend in this comment.
http://www.yiiframework.com/wiki/155/the-directory-structure-of-the-yii-project-site/#c9444
I'm not sure if this is the correct way. But it works.

Controllers sub-folders inside sub-folders and routes

In Codeignitor application
Controllers/folder/sub-folder/sub-folder/my_controller.php
if i would like to access my_controller.php i can't do this. for that i am sure i need change routes.php file to do this.
$route['default_controller'] = "folder";
$route['folder/sub-folder/sub-folder'] = "folder/sub-folder/sub-folder/my_controller";
but is showing 404 error.
so my question is simple in controller folder how someone can use folder inside folders.
like this:
Controllers/folder/sub-folder/sub-folder/my_controller.php
and what is needed to do with routes.php, so i will not get 404 error.
I believe there is a link in the official forms talking about this. If I remember correctly CI 1.7 did not even support sub directories and was included recently and I think they still consider it a bug.
http://codeigniter.com/forums/viewthread/190563/
If you only have a few sub directories you can also put rules in your URI routing
http://codeigniter.com/user_guide/general/routing.html
Either will be acceptable so you can choose which one will help you the most or which will get done the fastest. The other option is looking into why you need so many directories, especially for the controllers because that will make your urls longer which could ding you on SEO and other factors.

kohana v3: using different templates for different subdomains

I have a kohana v3 app. 2 subdomains pointing to this app. what I have to setup that kohana uses a different template if the app called with subdomain2.example.com?
at the moment all calls (from subdomain1 and subdomain2) use the standard template: 'templates/default'
thank you!
daniel
First, get the subdomain name from $_SERVER['SERVER_NAME']:
list($subdomain) = explode('.', $_SERVER['SERVER_NAME'], 2);
Then choose what template to use based on the subdomain:
// Replace this with a switch() statement if you want to choose another way
$this->template = 'templates/'.$subdomain;
The above code should be placed in the Controller::before() method before you call parent::before(). This assumes that you are using the Controller_Template or an extension of it.
may anybody can help me: kohana v3: using different templates for different subdomains
danzzz, there are a few ways... (i dont have time to go into detail.. so i'll give a quick go here..) .. A) use URL rewriting to map bla.site.com to site.com/bla (and www.bla.com+bla.com to bla.com/www) ... use that first param as the trigger... then load a different module at the top of the stack so it can override anything from a lower module - this assumes anything that is overridable is kept in a module, otherwise, you can use it as a trigger any
where in the code...
and B) is really the same thing, but using that param as the view name or similar...
whenever i have something like that, i tend to leave my application folder empty, and have an application module near the top of the module stack.. that way, i can load a "skin" module higher up and have the cascading FS do all the hard work...
keep in mind that "skin" modules etc will need a strict set of rules and interfaces, if you make a change to the app, you need to know all the skins still work...

Categories