I have my view helper in Library/My/View/Helper/LoadSkin.php, I added this line in application.ini : resources.view.helperPath.My_View_Helper = "My/View/Helper" but I'm still getting
Fatal error: Uncaught exception 'Zend_Loader_PluginLoader_Exception' with message
'Plugin by name 'LoadSkin' was not found in the registry; used paths: Zend_View_Helper_: Zend/View
/Helper/;C:/Program Files (x86)/Zend/Apache2/htdocs/TinOuzel/application/views\helpers/'
This looks like ZF stills looks for helper in default path ;/
My namespacje is registered in bootstrap:
protected function _initAutoloader ()
{
$autoloader = Zend_Loader_Autoloader::getInstance();
$autoloader->registerNamespace('My_');
$autoloader->suppressNotFoundWarnings(true);
return $autoloader;
}
in this case , you must had overridden the default view object
in much clear example , you are using something like :
$view = new Zend_View();
mostly somewhere in your bootstrap file , just remove it and you would be okay
Related
I am creating a custom API for SuiteCRM. When I attempt to run the new API from {CRM Home}/custom/service/v4_1_custom I receive an 'HTTP ERROR 500'. There are not errors in the error_log file or the SuiteCRM.log file.
I have followed the method in the following two url's
https://fayebsg.com/2013/05/extending-the-sugarcrm-api-updating-dropdowns/
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_10.0/Integration/Web_Services/Legacy_API/Extending_Web_Services/
registry.php
<?php
require_once('service/v4_1/registry.php');
class registry_v4_1_custom extends registry_v4_1
{
protected function registerFunction()
{
parent::registerFunction();
$this->serviceClass->registerFunction('test', array(), array());
}
}
SugarWebServicesImplv4_1_custom.php
<?php
if(!defined('sugarEntry'))define('sugarEntry', true);
require_once('service/v4_1/SugarWebServiceImplv4_1.php');
class SugarWebServiceImplv4_1_custom extends SugarWebServiceImplv4_1
{
/**
* #return string
*/
public function test()
{
LoggerManager::getLogger()->warn('SugerWebServiceImplv4_1_custom test()');
return ("Test Worked");
} // test
} // SugarWebServiceImplv4_1_custom
I found the answer to this issue.
In the file {SuiteCRM}/include/entryPoint.php there are many files that are included thru require_once. In this list of require_once files, there were 4 files that were set as require not require_once. These were classes and therefore could not be included a second time. I changed these to require_once and the HTTP Error 500 went away and the custom APIs started working.
I have started learning zend framework. I am using version 1.12. I am using modular approach. I have created one module called 'admin'. Following the my structure of the site
application/
(...other directories)
modules/
admin/
controllers/
IndexController.php
forms/
Login.php
views/
scripts/
(...view scripts)
Bootstrap.php
In this module I have created one form called 'login' using zf tool. whose class is created like this.
class Admin_Form_Login extends Zend_Form
{
public function init()
{
}
}
now the problem comes when I called this form in my admin module's index controller.
class Admin_IndexController extends Zend_Controller_Action {
public function indexAction()
{
$form = new Admin_Form_Login;
}
}
It gives me error like this.
Fatal error: Class 'Admin_Form_Login' not found in E:\xampp\htdocs\novo\application\modules\admin\controllers\IndexController.php on line 13.
I am not sure what I am doing wrong. anybody, please help me.
I think you can do th enext things:
1. Enable autoloading for module's models:
in application.ini:
resources.modules = []
resources.views = []
resources.frontController.moduleDirectory = APPLICATION_PATH . "/modules"
Create form in modules/admin/models/Form/Login.php and call class Admin_Model_Form_Login
Check your module bootstrap. It should be:
class Admin_Bootstrap extends Zend_Application_Module_Bootstrap
i have navigation menu which is displayed to users based on certain action of the controller. here is what i am doing.
//in each controller-action where i want "action navigation menu"
public function indexAction()
{
$this->_helper->navigation()->renderActionNavigation();
}
public function newAction()
{
$this->_helper->navigation()->renderActionNavigation();
}
the navigation menu is displayed accordingly. here is my navigation.xml file.
<?xml version="1.0" encoding="UTF-8"?>
<configdata>
<item-index>
<new-item>
<label>New Item</label>
<route>admin-item-new</route>
</new-item>
<delete-item>
<label>Delete Item</label>
<uri>#</uri>
</delete-item>
</item-index>
<item-new>
<publish-unpublish-item>
<label>Save & Close</label>
<uri>#</uri>
</publish-unpublish-item>
<delete-item>
<label>Save & New</label>
<uri>#</uri>
</delete-item>
</item-new>
</configdata>
the parent element of each navigation menu represents a naming convention in the above navigation.xml file for example
`<item-index>` represents item{controller}index{action}
`<item-new>` represents item{controller}new{action}
//and so on
here is the action helper. Navigation.php i am using
class Zend_Controller_Action_Helper_Navigation extends Zend_Controller_Action_Helper_Abstract
{
private $_view = null;
public function direct()
{
$this->_view = Zend_Layout::getMvcInstance()->getView();
$this->_view->placeholder('action-navigation');
return $this;
}
public function renderActionNavigation()
{
$config = new Zend_Config_Xml(
APPLICATION_PATH.'/configs/navigation.xml', strtolower(
$this->getRequest()->getControllerName().'-'.
$this->getRequest()->getActionName()
)
);
$container = new Zend_Navigation($config);
$this->_view->partial('partials/_action-navigation.phtml', array('container' => $container));
}
}
and finally _action-navigation.phtml
<?php $this->placeholder('action-navigation')->captureStart(); ?>
<div class="statsRow">
<div class="wrapper" >
<?php foreach($this->container as $page): ?>
<?php endforeach; ?>
</div>
</div>
<?php $this->placeholder('action-navigation')->captureEnd(); ?>
My directory structure is as follows
/application
/layouts
admin.phtml
default.phtml
/modules
/admin
/controllers
/helpers
/Navigation.php
IndexController.php
/views
/helpers
/scripts
/partials
_action-navigation.pthml
sidebar.phtml
/index
/item
the weird behavior i am experiencing is. in my Bootstrap.php file there is an empty _initView() method. my application works properly if this method exist. note that this method is empty. but when i remove it it gives me following error.
Application error
Exception information:
Message: script 'partials/_action-navigation.phtml' not found in path (./views/scripts/)
i am not able to understand this behavior by Zend Framework. how is action-navigation code related to _initView method in Bootstrap? what is happening and any fix for this or any suggestion for improvement of my code?
Update:
The problem lies with this line of code
$this->_view->partial('partials/_action-navigation.phtml', array('container' => $container));
You forgot to add the name of the admin module as second argument:
$this->_view->partial('partials/_action-navigation.phtml', 'admin', array('container' => $container));
I Suggest you use this clean and lightweight way, removing your dependence to inform actual module and mantaining your view script clean without captureStart and End (it's used ob_start... when u do captureStart-end)
$navigation = $this->view->navigation()->menu()->renderPartial($container, 'partials/_action-navigation.phtml');
// U can use placeholders `append` and `prepend` methods too, if u need more control in your placeholder content
$this->view->placeholder('action-navigation')->set($navigation);
I've been following the instruction on how to create custom routes from the book Zend Framework - A Beginners Guide
I've changed my application.ini file to include this routing information:
resources.router.routes.static-content.route = /content/:page
resources.router.routes.static-content.defaults.module = default
resources.router.routes.static-content.defaults.controller = static-content
resources.router.routes.static-content.defaults.view = static-content
resources.router.routes.static-content.defaults.action = display
Given the above configuration, I have this controller:
<?php
class Default_StaticContentController extends Zend_Controller_Action
{
public function init()
{
/* Initialize action controller here */
}
public function displayAction()
{
// action body
$page = $this->getRequest()->getParam('page');
if (file_exists($this->view->getScriptPath(null) .
'/' . $this->getRequest()->getControllerName() . '/' .
$page . $this->viewSuffix
)) {
$this->render($page);
}
else {
throw new Zend_Controller_Action_Exception('HLC - Page not found', 404);
}
}
}
I have a view named about.phtml in the APPLICATION_PATH/modules/default/views/static-content folder.
What ahppens is I get an error saying:
An error occurred
Page not found
Exception information:
Message: Invalid controller class ("StaticContentController")
Stack trace:
#0 /Applications/MAMP/htdocs/zend/library/Zend/Controller/Dispatcher/Standard.php(262): Zend_Controller_Dispatcher_Standard->loadClass('StaticContentCo...')
#1 /Applications/MAMP/htdocs/zend/library/Zend/Controller/Front.php(954): Zend_Controller_Dispatcher_Standard->dispatch(Object(Zend_Controller_Request_Http), Object(Zend_Controller_Response_Http))
#2 /Applications/MAMP/htdocs/zend/library/Zend/Application/Bootstrap/Bootstrap.php(97): Zend_Controller_Front->dispatch()
#3 /Applications/MAMP/htdocs/zend/library/Zend/Application.php(366): Zend_Application_Bootstrap_Bootstrap->run()
#4 /Applications/MAMP/htdocs/HLC/public/index.php(26): Zend_Application->run()
#5 {main}
Request Parameters:
array (
'page' => 'about',
'module' => 'default',
'controller' => 'static-content',
'view' => 'static-content',
'action' => 'display',
)
Note that it is not rendering my customised Zend_Controller_Action_Exception but throwing the global error.
I'm using the URL: http://hlc.local:8888/content/about
The default index action works ok, just this routing that's not working.
if you are actually following the book closely, you have an extra line in your route declaration and your controller class should be StaticContentController.
here is the route definition from the book that does work.
resources.router.routes.static-content.route = /content/:page
resources.router.routes.static-content.defaults.module = default
resources.router.routes.static-content.defaults.controller = static-content
resources.router.routes.static-content.defaults.action = display
I still have this code laying around from last summer.
I found this book less then satisfactory and not really for beginners. It fails to address the Zend_Db component opting instead to introduce Doctrine 1.2. It's seems to be a trend that a number of these beginner/easy books feel that a full ORM is more useful then Zend_Db. If you are already familiar with Doctrine this approach works fine, otherwise it's a lot to ask of a beginner, to learn ZF and Doctrine at the same time.
Hope this helps.
I don't now what you use for autoloading. so that would helpful to determine.so far I understand your class named should be something like this ModulePath_ApplicationPath_ControllerName, so its Default_Application_StaticContentController.
and for better routing I preferred zend manual. you can try this tutorial for route. it would help for you.
I'm trying to deploy a website made with the Zend Framework. The website is running fine on my local environment, I'm trying to deploy it on my VPS. But I'm running into some difficulties.
Now it says the following:
*Fatal error: Class 'Doctrine_Manager' not found in /is/htdocs/wpxxxxx/www/mensenenjij/application/Bootstrap.php on line 12*
It properly includes the Doctrine classes but it can't instantiate a new Doctrine_Manager. Anybody knows why?
Bootstrap.php:
<?php
class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
{
protected function _initDoctrine()
{
require_once 'Doctrine/Doctrine.php';
$this->getApplication()
->getAutoloader()
->pushAutoloader(array('Doctrine', 'autoload'), 'Doctrine');
$manager = Doctrine_Manager::getInstance();
$manager->setAttribute(
Doctrine::ATTR_MODEL_LOADING,
Doctrine::MODEL_LOADING_CONSERVATIVE
);
$config = $this->getOption('doctrine');
$conn = Doctrine_Manager::connection($config['dsn'], 'doctrine');
return $conn;
}
}