Skip to content

Commit

Permalink
APC cache for production; FileSQLLogger; group keyword for routes
Browse files Browse the repository at this point in the history
  • Loading branch information
usu committed Mar 20, 2011
1 parent 8fb0774 commit 9cbb651
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 15 deletions.
14 changes: 4 additions & 10 deletions application/Bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,6 @@ public function _initAutoloader()

$autoloader = \Zend_Loader_Autoloader::getInstance();

$bisnaAutoloader = new \Doctrine\Common\ClassLoader('Bisna');
$autoloader->pushAutoloader(array($bisnaAutoloader, 'loadClass'), 'Bisna');

$appAutoloader = new \Doctrine\Common\ClassLoader('Inject');
$autoloader->pushAutoloader(array($appAutoloader, 'loadClass'), 'Inject');

$entityAutoloader = new \Doctrine\Common\ClassLoader('Entity', APPLICATION_PATH);
$autoloader->pushAutoloader(array($entityAutoloader, 'loadClass'), 'Entity');

Expand Down Expand Up @@ -151,21 +145,21 @@ protected function _initRoutes()

/* group */
Zend_Controller_Front::getInstance()->getRouter()->addRoute(
'group', new Logic\Route\Vanity(':group/:action/*',
'group', new Logic\Route\Vanity('group/:group/:action/*',
array('controller' => 'group','action' => 'show')));

Zend_Controller_Front::getInstance()->getRouter()->addRoute(
'group+id', new Logic\Route\Vanity(':group/:action/:id/*',
'group+id', new Logic\Route\Vanity('group/:group/:action/:id/*',
array('controller' => 'group','action' => 'show'),
array('id' => '\d+')));

/* group camp */
Zend_Controller_Front::getInstance()->getRouter()->addRoute(
'group+camp', new Logic\Route\Vanity(':group/:camp/:controller/:action/*',
'group+camp', new Logic\Route\Vanity('group/:group/:camp/:controller/:action/*',
array('controller' => 'camps','action' => 'show')));

Zend_Controller_Front::getInstance()->getRouter()->addRoute(
'group+camp+id', new Logic\Route\Vanity(':group/:camp/:controller/:action/:id/*',
'group+camp+id', new Logic\Route\Vanity('group/:group/:camp/:controller/:action/:id/*',
array('controller' => 'camps','action' => 'show'),
array('id' => '\d+')));

Expand Down
15 changes: 10 additions & 5 deletions application/configs/application.ini
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ resources.session.remember_me_seconds = 864000

autoloaderNamespaces[] = "PHPTAL"
autoloaderNamespaces[] = "Ztal"
autoloaderNamespaces[] = "Ecamp"
autoloaderNamespaces[] = "Bisna"
autoloaderNamespaces[] = "Inject"


; ------------------------------------------------------------------------------
Expand Down Expand Up @@ -71,11 +74,7 @@ pluginPaths.Bisna_Application_Resource = "Bisna/Application/Resource"
resources.doctrine.cache.defaultCacheInstance = default

; Cache Instance configuration for "default" cache
resources.doctrine.cache.instances.default.adapterClass = "Doctrine\Common\Cache\ArrayCache"
resources.doctrine.cache.instances.default.namespace = "Application_"
; resources.doctrine.cache.instances.default.options.servers.0.host = localhost
; resources.doctrine.cache.instances.default.options.servers.0.port = 11211

resources.doctrine.cache.instances.default.adapterClass = "Doctrine\Common\Cache\ApcCache"


; ------------------------------------------------------------------------------
Expand All @@ -96,6 +95,7 @@ resources.doctrine.dbal.connections.default.parameters.password = "root"




; ------------------------------------------------------------------------------
; Doctrine ORM Configuration
; ------------------------------------------------------------------------------
Expand Down Expand Up @@ -141,3 +141,8 @@ phpSettings.display_startup_errors = 1
phpSettings.display_errors = 1
resources.frontController.params.displayExceptions = 1

resources.doctrine.cache.instances.default.adapterClass = "Doctrine\Common\Cache\ArrayCache"

resources.doctrine.orm.entityManagers.default.proxy.autoGenerateClasses = true

; resources.doctrine.dbal.connections.default.sqlLoggerClass = "Ecamp\DBAL\Logging\FileSQLLogger"
59 changes: 59 additions & 0 deletions library/Ecamp/DBAL/Logging/FileSQLLogger.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<?php
/*
* $Id$
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.doctrine-project.org>.
*/

namespace Ecamp\DBAL\Logging;

/**
* A SQL logger that logs to a file
*
*/
class FileSQLLogger implements \Doctrine\DBAL\Logging\SQLLogger
{
/**
* {@inheritdoc}
*/
public function startQuery($sql, array $params = null, array $types = null)
{
$myFile = APPLICATION_PATH . "/../tmp/sqllog.txt";

$f = fopen($myFile, 'a');

fwrite($f, $sql . PHP_EOL );

if ($params) {
fwrite($f, var_export($params, true));
}

if ($types) {
fwrite($f, var_export($types, true));
}

fclose($f);
}

/**
* {@inheritdoc}
*/
public function stopQuery()
{

}
}

0 comments on commit 9cbb651

Please sign in to comment.