Onlime Webhosting unterstützt Zend Framework und verwendet es in zahlreichen internen Projekten / Kunden-Sites. Bei der Entwicklung eines mittleren bis grossen Webprojekts auf PHP empfehlen wir Ihnen Zend Framework.
Onlime stellt sämtlichen Kunden auf dem Webserver die stets aktuellste stabile Version von Zend Framework zur Verfügung unter folgendem Pfad:
/var/www/shared/zend/library
Aktuellste Komponenten, die von Zend noch nicht in die Standard Library aufgenommen wurden und sich im sog. Incubator befinden, stehen ebenfalls bereit.
| Version | Letztes Update | Pfad | Beschrieb |
|---|---|---|---|
| 1.11.11 | 2011-09-30 | /var/www/shared/zend | stets die aktuellste stabile Version |
| incubator | 2011-09-30 | /var/www/shared/zend-incubator | aktuellster SVN-checkout des incubators (testing) |
| trunk | 2011-09-30 | /var/www/shared/zend-trunk | aktuellster SVN-checkout von trunk (testing) |
Zend Framework eignet sich genauso gut unter PHP 5.2.x wie unter PHP 5.3. Wir lassen zahlreiche Projekte parallel laufen unter beiden Versionen und es gibt keinerlei Kompatibilitätsprobleme mit PHP. Zend Framework ist 100% kompatibel mit PHP 5.3. Zögern Sie also nicht, gleich auf PHP 5.3 umzusteigen!
Das empfohlene Bootstrapping (index.php) unter Zend Framework 1.11.x sieht so aus:
<?php // Define path to application directory defined('APPLICATION_PATH') || define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/../application')); // Define application environment defined('APPLICATION_ENV') || define('APPLICATION_ENV', (getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'production')); // Ensure Zend Framework library is on include_path set_include_path(implode(PATH_SEPARATOR, array( '/var/www/shared/zend/library', get_include_path(), ))); /** Zend_Application */ require_once 'Zend/Application.php'; // Create application, bootstrap, and run $application = new Zend_Application( APPLICATION_ENV, APPLICATION_PATH . '/configs/application.ini' ); $application->bootstrap() ->run();
Die minimale Konfiguration in application/configs/application.ini sieht in etwa so aus:
[production] ;error reporting phpSettings.display_startup_errors = 0 phpSettings.display_errors = 0 ;set timezone phpSettings.date.timezone = Europe/Zurich ;include path includePaths.library = APPLICATION_PATH "/../library" includePaths.models = APPLICATION_PATH "/models" ;bootstrap bootstrap.path = APPLICATION_PATH "/Bootstrap.php" bootstrap.class = "Bootstrap" ;resources.frontController resources.frontController.env = APPLICATION_ENV resources.frontController.controllerDirectory = APPLICATION_PATH "/controllers" ;resources.layout resources.layout.layoutPath = APPLICATION_PATH "/layouts/scripts" ;resources.view resources.view.encoding = utf-8 ;resources misc resources.locale.default = de_CH ;resources.db resources.db.adapter = Pdo_Mysql resources.db.params.host = localhost resources.db.params.username = usr_web33_1 resources.db.params.password = xxxxxxxx resources.db.params.dbname = usr_web33_1 resources.db.params.charset = UTF8 resources.db.isDefaultTableAdapter = true [staging : production] [testing : production] phpSettings.display_startup_errors = 1 phpSettings.display_errors = 1 [development : production] phpSettings.display_startup_errors = 1 phpSettings.display_errors = 1 resources.db.params.password = ******** limits.top10verleih = 365
Onlime bietet Ihnen eine einfache Demo-Applikation „zfskeleton“ an zum Download via Subversion:
# svn co https://svn.onlime.ch/public/zfskeleton/trunk zfskeleton
Sie können den Code auch via Trac durchstöbern: https://trac.onlime.ch/public/browser/zfskeleton/trunk
Falls Sie nicht vertraut sind mit Subversion, können Sie alternativ das Projekt in der aktuellsten Version als .zip herunterladen: zfskeleton.zip
Der Verzeichnisbaum des Zend Framework Projekts unter Eclipse/PDT sieht dann in etwa so aus:
/public. Wir schlagen Ihnen folgende zwei Lösungsvarianten für's Deployment vor:
Wir splitten also unser Zend Framework Projekt auf in zwei Teile. Der Inhalt vom public Verzeichnis kopieren wir nach /public_html/www (resp. den entsprechenden webroot Ihrer Subdomain):
/public_html/www/ |-- .htaccess |-- _files |-- css |-- images `-- index.php
.htaccess. Unter Umständen werden diese in Ihrem FTP-client nicht angezeigt.
Den Rest des Projekts kopieren wir nach /includes/zfskeleton:
/includes/zfskeleton/ |-- application |-- library `-- tmp
Nun passen wir noch den Pfad zu unserem Applikations-Verzeichnis an in /public_html/www/index.php:
// Define path to application directory defined('APPLICATION_PATH') || define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/../../includes/zfskeleton/application'));
Im webroot (/public_html/www) befinden sich also nur die Dateien aus public, der Rest der Applikation ist ausserhalb des webroots „versteckt“.
basierend auf:
Dies wäre die einfachere, jedoch etwas unsicherere Variante. Wir belassen alles in Originalform und kopieren das gesamte Zend Framework Projekt nach /public_html/www:
/public_html/www/ |-- .htaccess |-- application |-- library |-- public `-- tmp
Den Pfad zu unserem Applikations-Verzeichnis in /public_html/www/index.php belassen wir:
// Define path to application directory defined('APPLICATION_PATH') || define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/../application'));
Damit wir auf unser Projekt nicht extra via /public zugreifen müssen, haben wir in .htaccess folgende Rewrite Rules definiert (Dieses zusätzliche .htaccess ist bereits in unserer Demo-Applikation enthalten):
# .htaccess
# used in shared hosting environments. Don't remove public/.htaccess !
SetEnv APPLICATION_ENV development
RewriteEngine On
RewriteRule ^\.htaccess$ - [F]
RewriteCond %{REQUEST_URI} =""
RewriteRule ^.*$ /public/index.php [NC,L]
RewriteCond %{REQUEST_URI} !^/public/.*$
RewriteRule ^(.*)$ /public/$1
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^.*$ - [NC,L]
RewriteRule ^public/.*$ /public/index.php [NC,L]
.htaccess im Wurzel-Verzeichnis des ZF Projektes mitkopiert haben, als auch die zweite Datei public/.htaccess.
Gewisse Anleitungen zum Zend Framework empfehlen Ihnen, APPLICATION_ENV direkt im .htaccess zu setzen:
SetEnv APPLICATION_ENV development
Achtung: Diese Art, eine Umgebungs-Variable (environment variable) zu setzen wird von Onlime Webhosting NICHT unterstützt. SetEnv wird ignoriert.
Als Alternative, ändern Sie bitte den Wert von APPLICATION_ENV direkt in Ihrer index.php:
// Define application environment defined('APPLICATION_ENV') || define('APPLICATION_ENV', (getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'development'));