I need two language versions of my web site which will be located in domainname/lang1/somecontroller and domainname/lang2/somecontroller urls. What architecture of routes file allow me to avoid of duplicating controllers declaration for every language?
* /{language}/MyController Application.MyController
should allow you to access both languages, and you then have access to the language passed in, in the controller, if you wish.
Related
I was wondering is there any example or good practice in Revel of making application module, related to subdomain.
For example, we have site.com, which is default application module and want to add an additional admin module for admin.site.com subdomain. The main problem I can see at this point is that we need to
dynamically determine what module should be used (using an interceptor before request)
switch routing in order to avoid collisions (since there may be overlapping routes, such as / for default module and / for admin module)
Does anyone implemented such application architecture in revel? Any related advice would be very helpful.
I have made a SAS based web builder which creates seperate urls:
(www.abc.com/user/somename) using codeignitor for each registered user.
Now how i can provide facility to users, so that they can map their own domain name ?
If I'm not wrong to understand your question than this might be what you needed
Setting your own routing rules
Routing rules are defined in your application/config/routes.php file. In it you'll see an array called $route that permits you to specify your own routing criteria. Routes can either be specified using wildcards or Regular Expressions
A typical wildcard route might look something like this:
$route['user/(:any)'] = "your_controller/your_function/$1";
Reference URI Routing. You can learn from provided link how to make dynamic url's
What is the best way to use codeIgniter with BoilerplateJS? should I put the codeIgniter folder in a BoilerplateJS folder or the contrary? Or something else? Need to make an authentifcation page in codeigniter and redirect the application in boilerplateJS.
Thanks.
I tried BoilerplateJS with CI in the following way:
Basically this is including BoilerplateJS in CodeIgniter folder.
I included all the BoilerplateJS code except the index file in to a folder named public which is in the root folder of CodeIgniter. The index file is placed in the views folder and will be loaded by a controller. (See the image)
For this to work some file paths had to be tweaked.
File paths in boilerplatejs index file (boilerplate.html in my case) had to be changed as follows:
./libs/jquery/jquery-min.js >>to>> public/libs/jquery/jquery-min.js
./libs/underscore/underscore-1.3.3.js >>to>> public/libs/underscore/underscore-1.3.3.js
and so on.
In main.js requirejs path configurations should be changed to:
require.config({
//Let's define short alias for commonly used AMD libraries and name-spaces.
paths : {
// requirejs plugins in use
text : 'libs/require/text',
i18n : 'libs/require/i18n',
path : 'libs/require/path',
// namespace that aggregate core classes that are in frequent use
Boiler : './app/core/_boiler_'
}
});
And in your controller you can load boilerplatejs by: $this->load->view('boilerplate.html');
I was thinking of integrating BoilerplateJS and CodeIgniter and probably use codeignighter-rest server for some time.
If all goes well I will share the code within the week.
A sample project is available at: https://github.com/slayerjay/codeigniter-boilerplatejs
EDIT Adding my view on CodeIgniter and BoilerplateJS
Firstly I have not (yet) done any major projects with BoilerplateJS and Codeigniter. But I have done projects using CI and the CI REST Server and know BoilerplateJS in and out.
I do not have much experience with other PHP frameworks (I have meddled with cakePHP and some others) but for me CI helps me to organize my code according to MVC pattern in a clean way, and provides excellent helper libraries and documentation.
As the OP rightly said, authentication is handled best outside BoilerplateJS and this can be done nicely with something like ion-auth for CI. After the user is authenticated and the SPA is loaded, the rest of the calls will be handled by the CodeIgniter REST server.
In this case you won’t be using much of the View aspect of your MVC architecture, but CI’s models and helpers would be of great help.
If you just need a simple REST server you can go with some lightweight solution that just provides REST type routing, but in many cases you will need to interact with a database and do some data processing.
So if you have decided to have a PHP backend for your application, Codeigniter with the REST server is a good choice.
I am running multiple applications with a single Codeigniter system/ folder using the recommended way on the Codeigniter wiki. Each application runs fine and I can link between apps using absolute URLs.
Is there some way I can use or extend the URL helper class (functions like anchor(), redirect()... etc.) to generate links to controllers across applications. I would like to avoid absolute URLs
Thanks!
You can use Matchbox or Modular separation and creat multiple modules. Then you can add controllers, models etc in each module.
in yii i could have mvc components (acts like an own application). could i have this too in codeigniter?
eg. in SYSTEM/APPLICATION have a folder called COMPONENTS and in there i put stand-alone applications that would be a part of the application. components like ADDRESS BOOK, MAIL, TWITTER and so on. every component folder has folders like: models, views, controllers, config etc.
so a component model extends the application model which in turn extends system's (code igniter) model. the same goes for view and controller.
i've already got a lot of these components which i want to use in codeigniter. is it good idea to place them as i said in SYSTEM/APPLICATION/COMPONENTS or is there best practice for this?
You can do this in CodeIgniter using v1.7.2 or 2.0, but using Packages as Billiam suggested would not work and sadly he is just confusing you.
You are basically looking for a HMVC architecture and this can be provided with a system called Modular Separation.
That works with CodeIgniter 1.7.2 and I have patched it to work with the (still unfinished) CodeIgniter 2.0 branch on the link in the entry.
Not by default in CI 1.7.2, but 'packages' will be available in 2.0.
Added ability to set "Package" paths -
specific paths where the Loader and
Config classes should try to look
first for a requested file. This
allows distribution of
sub-applications with their own
libraries, models, config files, etc.
in a single "package" directory. See
the Loader
class documentation for more
details.
From: http://bitbucket.org/ellislab/codeigniter/src/tip/user_guide/changelog.html
Also, take a look at Modular Extensions - HMVC