ZendFramewok en una carpeta

Few questions about ZendFramework:

  1. When creating a new project, is it possible to have everything in one folder, like CodeIgniter. So an application and a system folder, or something similar to that?

  2. When I finish a project with ZendFramework, how hard/easy is it to put in on a server (without using a console - shared hosting)?

  3. Can I use ZendFramework without Terminal when developing? Say if I was making a new class using an FTP client?

Gracias de antemano! :)

preguntado el 31 de julio de 12 a las 12:07

1 Respuestas

Zend Framework is like any other framework (CakePHP, CodeIgniter, Symfony...) and you can setup new project via CLI command (project generator) or manually setting up project folders and include paths.

Best practice would be to use manual approach in form similar to this:

/project/
/project/vendors/...  - all vendor libraries you may use in your project
/project/lib/... - your common libraries (if you have some)
/project/application/... - application files like controllers, views, temp folders etc...

Ejemplo:

/project/vendors/Zend/... (zend framework)
/project/vendors/Symfony/... (symfony framework)
/project/lib/MyLib/... (your lib)
/project/application/Bootstrap.php
/project/public_html/index.php

index.php snippet:

<?php
define('VENDORS_PATH', '/project/vendors');
define('LIB_PATH', '/project/lib');
set_include_path(
    LIB_PATH . PATH_SEPARATOR . 
    VENDORS_PATH . PATH_SEPARATOR . 
    get_include_path()
);

// setup class autoloading
require_once VENDORS_PATH . '/Zend/Loader/Autoloader';
$autoloader = Zend_Loader_Autoloader::getInstance();
$autoloader->setDefaultAutoloader(create_function('$class', "include str_replace('_', '/', \$class) . '.php';"));
$autoloader->setFallbackAutoloader(true);

// run application, include Symfony or MyLib files...

As for migrating your project on a production server, you should first setup your projects config with environment settings.

Example setup.ini:

[production]
database.hostname = localhost
database.username = username
database.password = password1
database.dbname = live_db

[staging:production]
database.hostname = localhost
database.username = root
database.password = password2
database.dbname = local_db

Using apache .htaccess files makes it easy to setup environment for config to load:

.htaccess file in local enviroment:

SetEnv APPLICATION_ENV staging

.htaccess file in production environment:

SetEnv APPLICATION_ENV production

index.php snippet using environment variables:

<?php
...
define('APPLICATION_ENV', getenv('APPLICATION_ENV'));
$config = new Zend_Config_Ini(APPLICATION_LIB . '/setup.ini', APPLICATION_ENV);
...

Respondido 31 Jul 12, 12:07

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.