Codeigniter

Codeigniter per Konsole bzw. php-cli

Codeigniter per Konsole bzw. php-cli

Hab hier ein cooles Script gefunden um CI auf der Konsole auszuführen.

http://benjaminmock.de/codeigniter-auf-der-konsole-kommandozeile/

Codeigniter mod_rewrite

Codeigniter mod_rewrite

Hier ist der Src für die .htaccess diese legt man einfach ins Stammverzeichnis.
Wenn CI z.b. unter http://localhost/codeigniter liegt muss man die RewriteBase anpassen und statt
RewriteBase / ändern in
RewriteBase /codeigniter/


    RewriteEngine On
    RewriteBase /

    #Removes access to the system folder by users.
    #Additionally this will allow you to create a System.php controller,
    #previously this would not have been possible.
    #'system' can be replaced if you have renamed your system folder.
    RewriteCond %{REQUEST_URI} ^system.*
    RewriteRule ^(.*)$ /index.php?/$1 [L]

    #Checks to see if the user is attempting to access a valid file,
    #such as an image or css document, if this isn't true it sends the
    #request to index.php
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php?/$1 [L]



    # If we don't have mod_rewrite installed, all 404's
    # can be sent to index.php, and everything works as normal.
    # Submitted by: ElliotHaughin

    ErrorDocument 404 /index.php

Jetzt muss man folgende Änderungen in der system/application/config/config.php vornehmen

#$config['index_page'] = "index.php";
$config['index_page'] = "";
...
#$config['rewrite_short_tags'] = FALSE;
$config['rewrite_short_tags'] = TRUE;

Das wars

Automatische config[base_url] bei Codeigniter

Automatische config[base_url] bei Codeigniter

Mit diesem Snippet konfiguriert sich die $config['base_url'] automatisch

$config['base_url'] = "http://".$_SERVER['HTTP_HOST'] . preg_replace('@/+$@','',dirname($_SERVER['SCRIPT_NAME'])).'/';

Quelle: http://www.includemedia.de/de/magazin/codeigniter-erste-schritte/