How to switch between $application_folder in ci? - codeigniter

I am developing an app that has two application under codeigniter!
My folders is look like this:
application
|- admin
|- site
I want to switch between this, Also i know that the configuration for this setting is: $application_folder
Actually i want to know how to switch between (under what condition)
$application_folder = 'application/admin';
and
$application_folder = 'application/site';

Related

How do I change the default url "/posts/" routing in a Hugo site?

I have created a new Hugo project. By default the urls route to mysite.com/posts/my-first-post. However I'm deploying to an existing domain where the url path for the posts is mysite.com/blog/my-first-post. How can I configure Hugo to go to /blog instead of /posts when view individual blog posts?
I've tried adding:
[permalinks]
post = "/blog/:slug"
To my config.toml file and then running hugo server --disableFastRender so it looks for changes and restarted server but I haven't been able to change the url structure. How might I go about doing this? Currently running anake theme.
Shoulda been posts instead of post.
config.toml
baseURL = "https://connorleech.info/"
languageCode = "en-us"
title = "Connor Leech"
theme = "ananke"
[permalinks]
posts = "blog/:title"

Default controller (under modules) not loading under HMVC, CodeIgniter, throws 404 err

Just migrated my CI from localhost to live. Everything works fine on localhost with same settings.
Here're the folder/file structure and contents of routes.php
-application
--controllers
---Home.php
--modules
---specs
----controllers
-----Specs.php
----models
----views
$route['default_controller'] = 'Specs/index';
//$route['default_controller'] = 'Home/index';
$route['404_override'] = 'Errors/show_404';
$route['translate_uri_dashes'] = FALSE;
Both Specs and Home controllers have index method. When I load the home page url with Specs/index as default controller, I get 404 error. But if I change the default controller to Home/index, it loads just fine. Strange. Everything else works just fine on whole site. Can't figure out.
The website is live but I'm not sure if providing url is allowed, so I'm including spaces in it. It's unspecs dott comm. Admin/Mods may please remove if url isn't allowed.
Thanks for reading.
I think you are doing mistake in routing, for HMVC it should be like that -
$route['default_controller'] = '<folder name>/<controller name>/<function name>';
$route['default_controller'] = 'specs/Specs/index';
Please follow this, hope it will work fine.
Try this https://stackoverflow.com/questions/6529026/codeigniter... But better use standart folder for default controller /application/controllers

Codeigniter setup multiple environment

I am about to make my website goes live, but I face a problem that after uploading the entire website to the server from local machine I will need to change the config file and upload to the server, but when I run in local machine I need to reset the config again. I was wondering is there any other way solve this issue ?
Thank you.
If you are talking about changing your base url all the time.
First place this code below on index.php
if (isset($_SERVER['HTTP_HOST'])) {
$base_url = isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) == 'on' ? 'https' : 'http';
$base_url .= '://'. $_SERVER['HTTP_HOST'];
$base_url .= str_replace(basename($_SERVER['SCRIPT_NAME']), '', $_SERVER['SCRIPT_NAME']);
} else {
$base_url = 'http://localhost/';
}
define('HTTP_SERVER', $base_url);
unset($base_url);
And then in the config.php
$config['base_url'] = HTTP_SERVER;
There is no shortcuts for this. It means when your project is in local you have to setup local, when live you have to setup for live.
Explanation and Tips
At the first time you code with project in local. So you have to
setup it correctly. Cz its will be same on live hosting.
So first time when you move all the files and folders to Live Host
you have to change, Database Configs, BaseUrl..
Then if you edit some thing on your localhost and you need to live
the site, Just move Controller, View, Model folders only. Do not move
the Config Folder(if any change do it manually).
So each and every time when you move the site, your config will be remain same at it is.
When you moving site to live, in root(outside application folder) edit index.php with following.
Change this to
define('ENVIRONMENT', 'development'); # shows all the run time errors
This
define('ENVIRONMENT', 'production'); # hide those and run the web smoothly, unless 500 or 404

hmvc codeigniter uri routing

I have and CI hmvc structure as below:
application
config
config.php
routes.php
...
modules
login
personal
config
config.php
routes.php
controllers
libraries
models
views
HMVC works fine. So, here's my problem: Inside /modules/personal/config/routes.php i have this:
$route['personal/empleados/actualizar.legajo'] = 'personal/empleados/actualizar_legajo/';
$route['personal/empleados/nuevo-cargo'] = 'personal/empleados/nuevo_cargo/';
But it doen't work. The file is loaded but routing doesn't work.
If i cut and copy these two lines and paste them inside: /application/config/routes.php, works.
Can anybody tell me why ? Because i have several modules and i would like to do this inside each modules/module-name/config/config.php
Thanx, in advance.
Have you tried to set the default controller in each module ?
You may also need to add the folder path.
modules/personal/config/routes.php
$route['default_controller'] = 'personal';
// OR //
$route['default_controller'] = 'personal/personal';
Thanx for your answer.
I set my default controller as you tell but it fails anyway.
On the other hand i found a solution (?) as follow on modules/module-name/config/routes.php
$route['personal/empleados/nuevo.cargo'] = 'empleados/nuevo_cargo/';
and... IT WORKS. I don't know why. But it works.

General URL for restcall on both server and on development machine,

My restcall on my devoplment machine is this:
return $resource('http://127.0.0.1/projectname/index.php/api/pipedata/pipes/format/json', {}, {});
Since I have several projects on my dev machine, I cant have it on root.
But on my server I have it on root so the correct url is:
http://127.0.0.1/index.php/api/pipedata/pipes/format/json
"projectname" is removed.
Whats the best practice to solve this? On server or client side?
I have php with codeigniter on server and angular js on client.
You can create a config file for different environment with an variable called ApiDomain like this
In dev configuration config_dev.js:
config = {};
config.ApiDomain = 'http://127.0.0.1/projectname';
In prod configuration config_prod.js:
config.ApiDomain = 'http://127.0.0.1';
Then in code you can refer to config.ApiDomain
return $resource(config.ApiDomain +'/index.php/api/pipedata/pipes/format/json', {}, {});
When deploy your code you can rename config_dev.js or config_prod.js to config.js for dev or prod in CI and you only need to refer to config.js in your code.

Resources