Search the Community
Showing results for tags 'zend framework 2'.
-
I don't want this thread to turn in to a "Let's burn ZendFramework 2, be a hipster". I'd like constructive answers with this topic since there are a number of questions I have, I'd love to understand how to implement ZendFramework 2 in a simple, logical way. To start, I have downloaded the ZendFramework 2, and immediately I was asked to use composer to install it, except, I hate Composer. Instead I created the following structure: /app/ /config/ /data/ /module/ /vendor/ /DoctrineOrm/ /Zend/ /public/ I then installed the Skeleton Application, this was following the examples on the ZF documentation. I don't like creating php files that look like this: <?php return array( // Associative array of values; returned by executable php file. ); I don't agree with php scripts, that return associative arrays, in my opinion, configuration files should be plain text only, and should not be available to `include_once` or `require_once`. So after looking at the ZendFramework 2 documentation; they suggest the following: <?php // Define the existing working directory. chdir(dirname(__DIR__)); // Should composer not be used (because it's not useful at all). require 'init_autoloader.php'; // Finally Zends' idea of application code. Zend\Mvc\Application::init(require '../config/application.config.php')->run(); 1. I don't like the idea of the following; "init(require '../config/application.config.php')"; I would expect to simply load a config file, and parse it as the argument. 2. I would much prefer to use the "Zend\Config\Reader\Ini" class and parse an INI type config file. Another problem, I would like to implement an application, that isn't using the Skeleton Application. This is because, I don't like the "Module.php" class, and the large "<modulename>.config.php" config file. I don't like routes looking like the following: return array( 'router' => array( 'routes' => array( 'home' => array( 'type' => 'Zend\Mvc\Router\Http\Literal', 'options' => array( 'route' => '/', 'defaults' => array( 'controller' => 'App\Controller\Index', 'action' => 'index', ), ), ), // The following is a route to simplify getting started creating // new controllers and actions without needing to create a new // module. Simply drop new controllers in, and you can access them // using the path /app/:controller/:action 'application' => array( 'type' => 'Zend\Mvc\Router\Http\Literal', 'options' => array( 'route' => '/app', 'defaults' => array( '__NAMESPACE__' => 'App\Controller', 'controller' => 'Index', 'action' => 'index', ), ), 'may_terminate' => true, 'child_routes' => array( 'default' => array( 'type' => 'Segment', 'options' => array( 'route' => '/[:controller[/:action]]', 'constraints' => array( 'controller' => '[a-zA-Z][a-zA-Z0-9_-]*', 'action' => '[a-zA-Z][a-zA-Z0-9_-]*', ), 'defaults' => array( ), ), ), ), ), ), ), 'service_manager' => array( 'factories' => array( 'translator' => 'Zend\I18n\Translator\TranslatorServiceFactory', ), ), 'translator' => array( 'locale' => 'en_US', 'translation_file_patterns' => array( array( 'type' => 'gettext', 'base_dir' => __DIR__ . '/../language', 'pattern' => '%s.mo', ), ), ), 'controllers' => array( 'invokables' => array( 'App\Controller\Index' => 'App\Controller\IndexController' ), ), 'view_manager' => array( 'display_not_found_reason' => true, 'display_exceptions' => true, 'doctype' => 'HTML5', 'not_found_template' => 'error/404', 'exception_template' => 'error/index', 'template_map' => array( 'layout/layout' => __DIR__ . '/../view/layout/layout.phtml', 'application/index/index' => __DIR__ . '/../view/app/index/index.phtml', 'error/404' => __DIR__ . '/../view/error/404.phtml', 'error/index' => __DIR__ . '/../view/error/index.phtml', ), 'template_path_stack' => array( __DIR__ . '/../view', ), ), ); Again, a configuration file that looks like that is completely ridiculous, it's just stupid having to type all of that out. How would this be configured using an INI type file? I would like to understand, how can I use the ZendFramework 2, as a library of classes without all the overload, bloat and unnecessary configurations? How can I implement an application level of classes (controllers, forms, views and models) as well as modules? Are there any examples someone could potentially share? Preferably, not using composer, or the Zend Skeleton Application. Otherwise, is there another framework that could be suggested? (excluding the likes of; FuelPHP; CakePHP; CodeIgniter; YII; Laravel).
- 1 reply
-
- php
- zend framework 2
-
(and 1 more)
Tagged with:
-
Hi Guys, I have been playing around with zend 2 and all going well, as I am sure you are aware the documentation is still in its early stages and is incomplete in some places. The problem I have got is I am trying to find the correct way to populate the options of a select element from a model using the zend table gateway method. I got this working fine using doctrine, but decided to try the gateway way aswell, and I have to admit it has me a little stumped. Do any of you have an example of this, or a good reference for it? thanks
-
- zend framework 2
- form
-
(and 2 more)
Tagged with: