Skip to content
This repository has been archived by the owner on May 26, 2023. It is now read-only.

Commit

Permalink
Add ZendSkeletonApplication for beta 3
Browse files Browse the repository at this point in the history
  • Loading branch information
akrabat committed Feb 25, 2012
1 parent 450270a commit 2abf33a
Show file tree
Hide file tree
Showing 26 changed files with 1,095 additions and 0 deletions.
14 changes: 14 additions & 0 deletions config/application.config.php
@@ -0,0 +1,14 @@
<?php
return array(
'modules' => array(
'Application',
),
'module_listener_options' => array(
'config_cache_enabled' => false,
'cache_dir' => 'data/cache',
'module_paths' => array(
'./module',
'./vendor',
),
),
);
1 change: 1 addition & 0 deletions config/autoload/.gitignore
@@ -0,0 +1 @@
local.config.php
8 changes: 8 additions & 0 deletions config/autoload/README.md
@@ -0,0 +1,8 @@
About this directory:
=====================

By default, this application is configured to load all configs in
`./config/autoload/*.config.php`. Doing this provides a location for a
developer to drop in configuration override files provided by modules, as well
as cleanly provide individual, application-wide config files for things like
database connections, etc.
16 changes: 16 additions & 0 deletions config/autoload/global.config.php
@@ -0,0 +1,16 @@
<?php
/**
* Global Configuration Override
*
* You can use this file for overridding configuration values from modules, etc.
* You would place values in here that are agnostic to the environment and not
* sensitive to security.
*
* @NOTE: In practice, this file will typically be INCLUDED in your source
* control, so do not include passwords or other sensitive information in this
* file.
*/

return array(
// ...
);
16 changes: 16 additions & 0 deletions config/autoload/local.config.php.dist
@@ -0,0 +1,16 @@
<?php
/**
* Local Configuration Override
*
* This configuration override file is for overriding environment-specific and
* security-sensitive configuration information. Copy this file without the
* .dist extension at the end and populate values as needed.
*
* @NOTE: This file is ignored from Git by default with the .gitignore included
* in ZendSkeletonApplication. This is a good practice, as it prevents sensitive
* credentials from accidentally being comitted into version control.
*/

return array(
// ...
);
2 changes: 2 additions & 0 deletions data/cache/.gitignore
@@ -0,0 +1,2 @@
*
!.gitignore
49 changes: 49 additions & 0 deletions module/Application/Module.php
@@ -0,0 +1,49 @@
<?php

namespace Application;

use Zend\Module\Manager,
Zend\EventManager\StaticEventManager,
Zend\Module\Consumer\AutoloaderProvider;

class Module implements AutoloaderProvider
{
protected $view;
protected $viewListener;

public function init(Manager $moduleManager)
{
$events = StaticEventManager::getInstance();
$events->attach('bootstrap', 'bootstrap', array($this, 'initializeView'), 100);
}

public function getAutoloaderConfig()
{
return array(
'Zend\Loader\ClassMapAutoloader' => array(
__DIR__ . '/autoload_classmap.php',
),
'Zend\Loader\StandardAutoloader' => array(
'namespaces' => array(
__NAMESPACE__ => __DIR__ . '/src/' . __NAMESPACE__,
),
),
);
}

public function getConfig()
{
return include __DIR__ . '/config/module.config.php';
}

public function initializeView($e)
{
$app = $e->getParam('application');
$basePath = $app->getRequest()->getBasePath();
$locator = $app->getLocator();
$renderer = $locator->get('Zend\View\Renderer\PhpRenderer');
$renderer->plugin('url')->setRouter($app->getRouter());
$renderer->doctype()->setDoctype('HTML5');
$renderer->plugin('basePath')->setBasePath($basePath);
}
}
6 changes: 6 additions & 0 deletions module/Application/autoload_classmap.php
@@ -0,0 +1,6 @@
<?php
return array(
'Application\Controller\IndexController' => __DIR__ . '/src/Application/Controller/IndexController.php',
'Application\Controller\ErrorController' => __DIR__ . '/src/Application/Controller/ErrorController.php',
'Application\Module' => __DIR__ . '/Module.php',
);
12 changes: 12 additions & 0 deletions module/Application/autoload_function.php
@@ -0,0 +1,12 @@
<?php
return function ($class) {
static $map;
if (!$map) {
$map = include __DIR__ . '/autoload_classmap.php';
}

if (!isset($map[$class])) {
return false;
}
return include $map[$class];
};
2 changes: 2 additions & 0 deletions module/Application/autoload_register.php
@@ -0,0 +1,2 @@
<?php
spl_autoload_register(include __DIR__ . '/autoload_function.php');
97 changes: 97 additions & 0 deletions module/Application/config/module.config.php
@@ -0,0 +1,97 @@
<?php
return array(
'di' => array(
'definition' => array(
'class' => array(
'Zend\Mvc\Router\RouteStack' => array(
'instantiator' => array(
'Zend\Mvc\Router\Http\TreeRouteStack',
'factory'
),
),
),
),
'instance' => array(
// Inject the plugin broker for controller plugins into
// the action controller for use by all controllers that
// extend it.
'Zend\Mvc\Controller\ActionController' => array(
'parameters' => array(
'broker' => 'Zend\Mvc\Controller\PluginBroker',
),
),
'Zend\Mvc\Controller\PluginBroker' => array(
'parameters' => array(
'loader' => 'Zend\Mvc\Controller\PluginLoader',
),
),

// Setup the View layer
'Zend\View\Resolver\AggregateResolver' => array(
'injections' => array(
'Zend\View\Resolver\TemplatePathStack',
),
),
'Zend\View\Resolver\TemplatePathStack' => array(
'parameters' => array(
'paths' => array(
'application' => __DIR__ . '/../view',
),
),
),
'Zend\View\Renderer\PhpRenderer' => array(
'parameters' => array(
'resolver' => 'Zend\View\Resolver\AggregateResolver',
),
),
'Zend\Mvc\View\DefaultRenderingStrategy' => array(
'parameters' => array(
'baseTemplate' => 'layout/layout',
),
),
'Zend\Mvc\View\ExceptionStrategy' => array(
'parameters' => array(
'displayExceptions' => true,
'template' => 'error/index',
),
),
'Zend\Mvc\View\RouteNotFoundStrategy' => array(
'parameters' => array(
'notFoundTemplate' => 'error/404',
),
),

// Setup the router and routes
'Zend\Mvc\Router\RouteStack' => array(
'parameters' => array(
'routes' => array(
'default' => array(
'type' => 'Zend\Mvc\Router\Http\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(
'controller' => 'Application\Controller\IndexController',
'action' => 'index',
),
),
),
'home' => array(
'type' => 'Zend\Mvc\Router\Http\Literal',
'options' => array(
'route' => '/',
'defaults' => array(
'controller' => 'Application\Controller\IndexController',
'action' => 'index',
),
),
),
),
),
),
),
),
);
34 changes: 34 additions & 0 deletions module/Application/src/Application/Controller/ErrorController.php
@@ -0,0 +1,34 @@
<?php

namespace Application\Controller;

use Zend\Mvc\Controller\ActionController,
Zend\View\Model\ViewModel;

class ErrorController extends ActionController
{
const ERROR_NO_ROUTE = 404;
const ERROR_NO_CONTROLLER = 404;

public function indexAction()
{
$error = $this->request->getMetadata('error', false);
if (!$error) {
$error = array(
'type' => 404,
'message' => 'Page not found',
);
}

switch ($error['type']) {
case self::ERROR_NO_ROUTE:
case self::ERROR_NO_CONTROLLER:
default:
// 404 error -- controller or action not found
$this->response->setStatusCode(404);
break;
}

return new ViewModel(array('message' => $error['message']));
}
}
14 changes: 14 additions & 0 deletions module/Application/src/Application/Controller/IndexController.php
@@ -0,0 +1,14 @@
<?php

namespace Application\Controller;

use Zend\Mvc\Controller\ActionController,
Zend\View\Model\ViewModel;

class IndexController extends ActionController
{
public function indexAction()
{
return new ViewModel();
}
}
22 changes: 22 additions & 0 deletions module/Application/view/error/404.phtml
@@ -0,0 +1,22 @@
<h1>A 404 error occurred</h1>
<h2><?php echo $this->message ?></h2>

<?php if (isset($this->display_exceptions) && $this->display_exceptions): ?>

<?php if(isset($this->exception) && $this->exception instanceof Exception): ?>

<h3>Exception information:</h3>
<p>
<h4>Message:</h4>
<pre><?php echo $this->exception->getMessage() ?></pre>
<h4>Stack trace:</h4>
<pre><?php echo $this->exception->getTraceAsString() ?></pre>
</p>

<?php else: ?>

<h3>No Exception available</h3>

<?php endif ?>

<?php endif ?>
22 changes: 22 additions & 0 deletions module/Application/view/error/index.phtml
@@ -0,0 +1,22 @@
<h1>An error occurred</h1>
<h2><?php echo $this->message ?></h2>

<?php if (isset($this->display_exceptions) && $this->display_exceptions): ?>

<?php if(isset($this->exception) && $this->exception instanceof Exception): ?>

<h3>Exception information:</h3>
<p>
<h4>Message:</h4>
<pre><?php echo $this->exception->getMessage() ?></pre>
<h4>Stack trace:</h4>
<pre><?php echo $this->exception->getTraceAsString() ?></pre>
</p>

<?php else: ?>

<h3>No Exception available</h3>

<?php endif ?>

<?php endif ?>
25 changes: 25 additions & 0 deletions module/Application/view/index/index.phtml
@@ -0,0 +1,25 @@
<div class="hero-unit">
<h1>Welcome to <span class="zf-green">Zend Framework 2</span></h1>
<p>Congratulations! You have successfully installed the <a href="https://github.com/zendframework/ZendSkeletonApplication">ZF2 Skeleton Application</a>. You are currently running Zend Framework version <?php echo \Zend\Version::VERSION ?>. This skeleton can serve as a simple starting point for you to begin building your application on ZF2.</p>
<p><a class="btn btn-success btn-large" href="https://github.com/zendframework/zf2">Fork Zend Framework 2 on GitHub &raquo;</a></p>
</div>

<div class="row">
<div class="span4">
<h2>Follow Development</h2>
<p>Zend Framework 2 is under active development. If you are interested in following the development of ZF2, there is a special ZF2 portal on the official Zend Framework webiste which provides links to the ZF2 <a href="http://framework.zend.com/wiki/display/ZFDEV2/Home">wiki</a>, <a href="http://framework.zend.com/zf2/blog">dev blog</a>, <a href="http://framework.zend.com/issues/browse/ZF2">issue tracker</a>, and much more. This is a great resource for staying up to date with the latest developments!</p>
<p><a class="btn btn-success" href="http://framework.zend.com/zf2">ZF2 Development Portal &raquo;</a></p>

</div>
<div class="span4">
<h2>Discover Modules</h2>
<p>The community is working on developing a community site to serve as a repository and gallery for ZF2 modules. The project is available <a href="https://github.com/zendframework/modules.zendframework.com">on GitHub</a>. The site is currently live and currently contains a list of some of the modules already available for ZF2.</p>
<p><a class="btn btn-success" href="http://modules.zendframework.com/">Explore ZF2 Modules &raquo;</a></p>
</div>
<div class="span4">

<h2>Help &amp; Support</h2>
<p>If you need any help or support while developing with ZF2, you may reach us via IRC: <a href="irc://irc.freenode.net/zftalk.2">#zftalk.2 on Freenode</a>. We'd love to hear any questions or feedback you may have regarding the beta releases. Alternatively, you may subscribe and post questions to the <a href="http://framework.zend.com/wiki/display/ZFDEV/Mailing+Lists">mailing lists</a>.</p>
<p><a class="btn btn-success" href="http://webchat.freenode.net?channels=zftalk.2">Ping us on IRC &raquo;</a></p>
</div>
</div>

0 comments on commit 2abf33a

Please sign in to comment.