Welcome Guest, Not a member yet? Register   Sign In
Best-practice setting up CI with WAMP
#1

[eluser]MaartenDeGroote[/eluser]
Hi there everybody,

I'm thinking about moving over to CI for the development of my websites. I make extensive use of the jQuery library and use plugins like swfObject and sIFR.

I set up my local development environment using WAMP-server for windows. While playing around with WAMP and CI I was wondering if anybody has some best-practice ideas on setting up CI locally. I want to accomplish the following:

- Have multiple applications of CI running where each application represents one client website.
- Being able to address resources (css/js/images) with absolute urls instead of relative ones

Does anybody know how to configure this? I already know that I need to move the application folder out of the system folder and that I should change the index.php file accordingly. However, do I need to set up VirtualHost in WAMP or something like that? And what should be the base_url for each application in the config.php file in order to make use of absolute urls? Are there any other steps I need to take in order to get things working the way I want? Where do I put sIFR or jQuery for example? Questions, questions, questions...

Anyway, any help would be greatly appreciated. Maybe it's a good idea to outline how forum-members have set up their local environment?

Thanx in advance for your time!

Regards,

Martin
#2

[eluser]tomcode[/eluser]
I've stopped all special configurations and setups. Instead I keep all project related files under one folder :
- local : the project / site later to deploy, under svn, containing all files required (db dumps, AS classes, etc)
- maybe several other folders containing files I've received from the client, stuff I've been working on, zipped versions validated / deployed

The only exception are files related to offers, invoices and the mails.
#3

[eluser]designfellow[/eluser]
Hi,

I usually put my folders in same level.
Like this...

-system
-application
-images
-css
-js etc.


And i load the files in views like ..

<link rel="stylesheet" href="<?php echo base_url();?>css/defult.css" />

It works fine for me..


Happy Coding,
DesignFellow
#4

[eluser]Johan André[/eluser]
I configure a local dns to point to the working directory.
That way I don't need to access my site with http://localhost/my_site and can do http://mysite/
When I deploy the site on my webserver no paths have to be changed.

I can also reference my assets like:
Code:
<link rel="stylesheet" media="screen" href="/assets/css/style.css" />

I use this structure:
Code:
application
assets
  css
  js
  images
system
index.php
#5

[eluser]Reynolds[/eluser]
Mine's almost similar with the others.

application_name
- application (config, controller,models,views,etc)
- resources
- css (centralized)
- images (centralized)
- js (centralized)
- themes (specific per theme)
- default
- css
- images
- js
- index.php
- .htaccess

system
- 1.7.1
- 1.7.2

user_guide


-------------
Note:
- I've added a lot of definitions inside the bootstrap (index.php) that is used by routes.php, config.php, etc.

- Also I've made base_url() useless, coz I'm using now BASE_URL, others are:

Code:
// define a default application
    define("DEFAULT_APP","application");

    // if mod_rewrite is enabled, we could use .htaccess file to omit the "index.php"
    define("URL_REWRITE",true);

    // define the default bootstrap (e.g. 'index.php')
    define("DEFAULT_BOOTSTRAP", basename($_SERVER['SCRIPT_FILENAME']));

    // define a default application title.
    define("APP_TITLE","Framework");
    
    // define a default application theme.
    define("DEFAULT_THEME","default");

    // define the default route
    define("DEFAULT_ROUTE","home");

    // if within sub-directory, this must be defined
    $t = explode(DEFAULT_BOOTSTRAP,$_SERVER['PHP_SELF']);
    
    //define("BASE_URI",$_SERVER['REQUEST_URI']);
    define("BASE_URI",$t[0]);
    
    // define the default view prefix
    define("DEFAULT_VIEW_PREFIX","view_");

    // enable/disable scaffolding (true, or false)
    define("SCAFFOLDING",false);

    // define trigger (or secret) key for the scaffoling
    define("SCAFFOLDING_TRIGGER","k3yw0rd");

    // enable/disable profiler (true, or false)
    define("PROFILER",true);

    // enable/disable unit testing (true, or false) (see Test Driven Development)
    define("UNIT_TEST",false);

   // define which CI-system version to use
   define("CI_SYSTEM","1.7.2");

   // set to true if you want to use the ci-svn version (latest checkout from the trunk)
   define("CI_SVN",false);

and below the block of
Code:
/*
|---------------------------------------------------------------
| DEFINE APPLICATION CONSTANTS
|---------------------------------------------------------------
|
| EXT        - The file extension.  Typically ".php"
| FCPATH    - The full server path to THIS file
| SELF        - The name of THIS file (typically "index.php")
| BASEPATH    - The full server path to the "system" folder
| APPPATH    - The full server path to the "application" folder
|
*/
define('EXT', '.'.pathinfo(__FILE__, PATHINFO_EXTENSION));
define('FCPATH', __FILE__);
define('SELF', pathinfo(__FILE__, PATHINFO_BASENAME));
define('BASEPATH', $system_folder.'/');

Code:
define("THEME", BASE_URI . "resources/themes/" . DEFAULT_THEME . "/");
define("THEME_CSS_PATH", THEME . "css/");
define("THEME_JS_PATH", THEME . "js/");
define("THEME_IMG_PATH", THEME . "images/");

define("APP_RES_PATH", BASE_URI . "resources/");
define("APP_CSS_PATH", BASE_URI . "resources/css/");
define("APP_JS_PATH", BASE_URI . "resources/js/");                                
define("APP_IMG_PATH", BASE_URI . "resources/images/");                                

//////////////////////////////////////////////////////////////////
// make the base url dynamically.
// note: this allows drop-anywhere-and-run capability of the framework.
//       also, all resources are organized within application.


if(URL_REWRITE)
{
   define("BASE_URL","http://" . $_SERVER['HTTP_HOST'] . BASE_URI);
   define("BASE_URL_SSL","https://" . $_SERVER['HTTP_HOST'] . BASE_URI);
}
else
{
   define("BASE_URL","http://" . $_SERVER['HTTP_HOST'] . BASE_URI . DEFAULT_BOOTSTRAP);
   define("BASE_URL_SSL","https://" . $_SERVER['HTTP_HOST'] . BASE_URI . DEFAULT_BOOTSTRAP);
}
#6

[eluser]John_Betong[/eluser]
 
The way I handle localhost multiple applications is to have a separate _menu.php . Which has my sub-domains, current CodeIgniter projects, normal HTML sites and a call to my phpMyAdim().

 
// Maybe a better way and I am open to options
The normal PHP form radio-button names are:
1. passed back to _menu.php
2. checked to see if a $_GET['application'] was passed
3. if $_GET is set then set $_SESSION['_MENU_'] = $_GET['application']; and call header("Location: http://localhost/index.php");

 
The CodeIgninter index.php is virtually standard apart from:
Code:
// default to johns-jokes if no PHP $_SESSION set
   $_SESSION['_MENU_'] = isset($_SESSION['_MENU_']) ? $_SESSION['_MENU_'] : 'ci_jokes';

 
 
 
101




Theme © iAndrew 2016 - Forum software by © MyBB