My Codeigniter web application working good in my localhost, but in live server i am getting error Unable to locate the specified class: Hooks.php
In my localhost
application\config\hooks.php is empty file and
application\config\config.php setting $config['enable_hooks'] = FALSE;
How to solve? thanks in advance..
Enabling Hooks
The hooks feature can be globally enabled/disabled by setting the following item in the application/config/config.php file:
$config['enable_hooks'] = TRUE;
Defining a Hook
Hooks are defined in the application/config/hooks.php file. Each hook is specified as an array with this prototype:
$hook['pre_controller'] = array(
'class' => 'MyClass',
'function' => 'Myfunction',
'filename' => 'Myclass.php',
'filepath' => 'hooks',
'params' => array('beer', 'wine', 'snacks')
);
Also take reference from Hooks
This error is due to some missing file. Lots of answers are regarding Sessions and stuff.
I had my application working perfectly and suddenly this error occurred. I re-uploaded my applications folder and everything is back in order.
Related
I am working with the skeleton-application as a base, using the Vagrant / Composer setup. After the initial install I realised I would need the LDAP module. I then ran composer require zendframework/zend-ldap which ran successfully and I have located the files in ~/vendor/zendframework/zend-ldap.
The issue is when I add 'Zend\Ldap' to my ~/config/modules.config.php I encounter the following error:
Fatal error: Uncaught Zend\ModuleManager\Exception\RuntimeException: Module (Zend\Ldap) could not be initialized. in /var/www/vendor/zendframework/zend-modulemanager/src/ModuleManager.php:203 Stack trace: #0 /var/www/vendor/zendframework/zend-modulemanager/src/ModuleManager.php(175): Zend\ModuleManager\ModuleManager->loadModuleByName(Object(Zend\ModuleManager\ModuleEvent))
#1 /var/www/vendor/zendframework/zend-modulemanager/src/ModuleManager.php(97): Zend\ModuleManager\ModuleManager->loadModule('Zend\\Ldap') #2 /var/www/vendor/zendframework/zend-eventmanager/src/EventManager.php(322): Zend\ModuleManager\ModuleManager->onLoadModules(Object(Zend\ModuleManager\ModuleEvent))
#3 /var/www/vendor/zendframework/zend-eventmanager/src/EventManager.php(171): Zend\EventManager\EventManager->triggerListeners(Object(Zend\ModuleManager\ModuleEvent))
#4 /var/www/vendor/zendframework/zend-modulemanager/src/ModuleManager.php(120): Zend\EventManager\EventManager->triggerEvent(Object(Zend\ModuleManager\ModuleEvent))
#5 /var/www/vendor/zendfr in /var/www/vendor/zendframework/zend-modulemanager/src/ModuleManager.php on line 203
The ~/config/modules.config.php file:
/**
* List of enabled modules for this application.
*
* This should be an array of module namespaces used in the application.
*/
return [
'Zend\Session',
'Zend\Mvc\Plugin\Prg',
'Zend\Mvc\Plugin\Identity',
'Zend\Mvc\Plugin\FlashMessenger',
'Zend\Mvc\Plugin\FilePrg',
'Zend\Log',
'Zend\Form',
'Zend\Db',
'Zend\Router',
'Zend\Validator',
'Zend\Ldap', // All is well if this is commented out
'Application',
];
and the ~/config/application.config.php file:
/**
* If you need an environment-specific system or application configuration,
* there is an example in the documentation
* #see https://docs.zendframework.com/tutorials/advanced-config/#environment-specific-system-configuration
* #see https://docs.zendframework.com/tutorials/advanced-config/#environment-specific-application-configuration
*/
return [
// Retrieve list of modules used in this application.
'modules' => require __DIR__ . '/modules.config.php',
// These are various options for the listeners attached to the ModuleManager
'module_listener_options' => [
// This should be an array of paths in which modules reside.
// If a string key is provided, the listener will consider that a module
// namespace, the value of that key the specific path to that module's
// Module class.
'module_paths' => [
'./module',
'./vendor',
],
// An array of paths from which to glob configuration files after
// modules are loaded. These effectively override configuration
// provided by modules themselves. Paths may use GLOB_BRACE notation.
'config_glob_paths' => [
realpath(__DIR__) . '/autoload/{{,*.}global,{,*.}local}.php',
],
// Whether or not to enable a configuration cache.
// If enabled, the merged configuration will be cached and used in
// subsequent requests.
'config_cache_enabled' => true,
// The key used to create the configuration cache file name.
'config_cache_key' => 'application.config.cache',
// Whether or not to enable a module class map cache.
// If enabled, creates a module class map cache which will be used
// by in future requests, to reduce the autoloading process.
'module_map_cache_enabled' => true,
// The key used to create the class map cache file name.
'module_map_cache_key' => 'application.module.cache',
// The path in which to cache merged configuration.
'cache_dir' => 'data/cache/',
// Whether or not to enable modules dependency checking.
// Enabled by default, prevents usage of modules that depend on other modules
// that weren't loaded.
// 'check_dependencies' => true,
],
// Used to create an own service manager. May contain one or more child arrays.
// 'service_listener_options' => [
// [
// 'service_manager' => $stringServiceManagerName,
// 'config_key' => $stringConfigKey,
// 'interface' => $stringOptionalInterface,
// 'method' => $stringRequiredMethodName,
// ],
// ],
// Initial configuration with which to seed the ServiceManager.
// Should be compatible with Zend\ServiceManager\Config.
// 'service_manager' => [],
];
I have tried removing cache folder, running composer update, restarting Vagrant, adding the full path to the 'modules_path' array in application.config.php but it is always the same error. Interestingly I run into the same issue with 'Zend\View' that was included from the install, but a module such as 'Zend\Session' can be added to the modules.config.php file with no issues (They are all located in the vendor/zendframework directory)
Can anyone point me in the right direction to resolve this issue?
Zend\Ldap is one of the ZF components. As it does not have a Module.php in its /src directory which is mandatory for a module. So you do not need to initialize like other modules through modules.config.php to use it in your application.
This component is not included as required with default installation of ZF. So if you want to use any component, you must add them to autoloader. Once you added a component like this one composer require zendframework/zend-ldap in your project, you would then be able to use it.
Check this answer and this issue to be clear!
zend-ldap doesn't have a src/Module.php file, so you can't add it as a module. Also it doesn't seem to include a standard factory so you need to write one yourself. More info on how to set it up:
https://zendframework.github.io/zend-ldap/intro/
As others have noted, zend-ldap does not provide a Module class; it is simply a component that provides functionality. It has no service definitions, which is why there is no Module class.
Two things to note:
Install zendframework/zend-component-installer in your application: composer require --dev zendframework/zend-component-installer. When you do, any time you add another component to your application that exposes a Module class, it will prompt you, asking if you want to add it to your application configuration. (zend-component-installer is installed by default if you start your project with the zendframework/skeleton-application.)
We have recently opened our Zend Framework forums; consider directing your ZF questions there in the future, to make the answers easily discoverable for ZF users.
Is zend-ldap included in your project? If not Run in your terminal
composer require zendframework/zend-ldap
And you can disable caching in development process by enabling development mode: composer development-enable
I am trying to configure cakephp ver 2.6.0 to use redis engine by default. but somehow i am not able to make it work. any help will be highly appreciated.
Things Which i have tried so far..
Configured app/config folder 2 files , core.php and bootstrap.php. , according to the guidelines provided here in this blog configure cake with redis and this blog too Another cake-redis config setup
but i keep on getting errors like.
Fatal error: Uncaught exception 'CacheException' with message 'Cache engine session is not properly configured.' in C:\wamp\www\project\cakephp\cakephp_2.6.0\lib\Cake\Cache\Cache.php on line 181
CacheException: Cache engine session is not properly configured. in C:\wamp\www\project\cakephp\cakephp_2.6.0\lib\Cake\Cache\Cache.php on line 181
Any help will be highly appreciated.
I was having the same exact issue today while trying to setup CakePHP to use Redis as the cache engine.
Coincidentally, I also read the same setup instructions from the two blogs you linked to.
The reason was that I had copied pasted the Configure::write(...) code block from the Another cake-redis config setup blog post as it is and pasted it into the file without first commenting out the Configure::write(...) code block that was already in the core.php file.
I'm assuming that you have already successfully setup Redis on Windows and have installed the PHPRedis extension without any issues.
I am using the instructions from Another cake-redis config setup here.
In your app/Config/core.php file, comment out the following block: (this was starting at line 218 in my core.php)
Configure::write('Session', array(
'defaults' => 'php'
));
Instead, you can put this in: (You can change the values to suit your particular needs)
Configure::write('Session', array(
'defaults' => 'cache',
'timeout' => 100,
'start' => true,
'checkAgent' => false,
'handler' => array(
'config' => 'session'
)
));
After this, change the value of $engine to 'Redis', so it becomes:
$engine = 'Redis';
And then, put this code in, I put this in at the very end of the file: (Again, your values can be different depending on what your setup is)
Cache::config ('session', array (
'Engine' => $engine,
'Prefix' => $prefix . 'cake_session_',
'Duration' => $duration
));
And that's it. You're done! No need to change anything else.
To make sure that Redis is working properly with CakePHP, I ran the RedisEngine Test Suite that comes with CakePHP. You need to have PHPUnit installed for this to work.
It can be accessed via http://your-cakephp-project/test.php
Click on 'Tests' under Core and then click on 'Cache/Engine/RedisEngine'
If everything is working successfully, you should see all the tests pass.
Alternatively, you can use redis-cli at the command prompt to confirm that Redis is storing keys properly.
Once you have logged in by typing redis-cli, type KEYS *
This should give you a list of keys related to your CakePHP setup.
An example would be the "myapp_cake_core_object_map" key.
Hope this helps.
In the module.config.php files for zf-api-problem and zf-rest it says you can override 'display_exceptions' in the application config to get exception stack traces in the response.
'view_manager' => array(
// Enable this in your application configuration in order to get full
// exception stack traces in your API-Problem responses.
'display_exceptions' => false,
),
I have display_exceptions set to true in my Application module.config.php (from the skeleton app), however it gets overwritten when all the configs are merged. When I look at the state of the config in \ZF\ApiProblem\Listener\SendApiResponseListener, where the ApiProblemResponse is being constucted, 'display_exceptions' is set to false.
Is it merging in zf-api-problem and zf-rest configs after the application config and overwriting it?
How can I enable display_exceptions without changing it in the vendor modules?
When you enable development mode, The apigility copy The ./config/development.config.php.dist to ./config/development.config.php. This is merged with another configs. So, edit The .dist file, and disable and enable the development mode.
You could be right that the settings are overwritten by another config.
Try once to change the order of your application modules. So in your application.config.php:
<?php
return array(
'modules' => array(
'ZF\Hal',
'ZF\Rest',
'ZF\ApiProblem',
... more modules ...
'My\Custom\Module' // --> Set your 'display_exceptions' => true
// in the module.config.php of this module
)
)
I built a Silex project with an login mechanism.
Not being a Symfony expert, I strictly followed the guidelines here for the authentication process : http://silex.sensiolabs.org/doc/providers/security.html
... and it works fine on my development environment
However, when I pushed my project on my production server, I get the following error each time I try to log into my web app
[2012-12-18 16:35:33] CRITICAL: Symfony\Component\Security\Core\Exception\AuthenticationCredentialsNotFoundException:
A Token was not found in the SecurityContext. (uncaught exception) at
/my/app/path/vendor/symfony/security/Symfony/Component/Security/Http/Firewall/AccessListener.php line 53 [] []
which means that the following code in AccessListener.php
$this->context->getToken());
throws an expection
Given the fact that the same code works perfectly fine on my development environment, I assume it has something to do with my production server configuration.
I found this thread http://groups.google.com/forum/#!msg/symfony-devs/jKphNy_0Q2Y/vYfkAuyjSHEJ that suggests to add the following line to my project's .htaccess
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization},L]
with no result. I still get the "A Token was not found in the SecurityContext" exception.
Does anybody have an idea ?
Edit
The content of $app['security.firewalls'] is the following
$app->register(new Silex\Provider\SecurityServiceProvider(), array(
'security.firewalls' => array(
'login' => array(
'pattern' => '^/login$'
),
'admin' => array(
'pattern' => '^/',
'form' => array('login_path' => '/login', 'check_path' => '/admin/login_check'),
'logout' => array('logout_path' => '/admin/logout'), // url to call for logging out
'users' => array(
'admin' => array('ROLE_ADMIN', 'SOMEPASSWORD'),
),
)
)
));
It seems it has nothing to do with HTTP Basic Auth, because you don't use it in any of your firewalls. What you use is a firewall with a form entry point, which then uses session to store the security token.
I would suggest you to look at how sessions (and cookies) are managed on prod server compared to your dev environment.
Most likely the reason why this works on your local machine but not in your productive environment is that .htaccess is supported by Apache, while nginx does not bother wasting I/O and CPU time parsing this files
If you post your .htaccess I will show you how to translate this to performant nginx-readable configuration.
EDIT
Silex even has a configuration example for nginx
http://silex.sensiolabs.org/doc/web_servers.html
I created a module for social engine, which is zend based, and I added up my.sql file in settings folder, when I install this module, it installs properly but the my.sql file does not run.
I have a entry in the core_modules table. I see a package created in the packages folder, but the my.sql file is being ignored. Can anyone tell me what could be wrong.
In my manifest.php file, I have set the version to be 4.0.0.
After installation the module does not work, as the menuitems are not inserted, once I install them manually into the database it starts working.
Can anyone tell me what could be wrong. I tried renaming the file to my-install.php, my-install-4.0.0-4.0.1.php and change the version in manifest to 4.0.1 and reinstalled it but did not help. It says 0 query excuted everytime.
Thanks in advance!
I have found the problem my self, listing here to help others:
In my manifest file, located at application/modules/HelloworldModule/settings/manifest.php
return array (
'package' =>
array (
'type' => 'module',
'name' => 'helloworld-module',
'version' => '4.0.0',
'path' => 'application/modules/HelloWorldModule',
'title' => 'Hello World',
'description' => 'Say hello to the world!',
'author' => 'Hardik',
The only mistake was in the path, as you can see above, the path has "W" in capital while in real path its in small letter. This was the reason it was not able to find the my.sql file on the specified path, the rest of the module worked fine.
Note: I am on a linux server and the path are case sensitive.