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
)
)
Related
I have a composer package designed for use in other projects that has configurations, or rather default settings I'd like the end user to be able to adjust based on their intended use. The package itself can be configured to build things differently depending on the configurations passed to the package's builder class. I'd like there to be default settings, possibly in a settings.yml file (the medium is not a concern, *.conf, *.json, *.php), may be this should go within the package? But then I imagine if that were the case it would be hard for the end user to maintain as it would be overwritten during composer updates? Anyone know what the norm for storing composer vendor packages configs is?
$parameters = [
'handlers' => [
// various depending on client use
'//widget' => 'LivingMarkup\Component\Widgets\{name}',
'//img' => 'LivingMarkup\Component\Img',
'//a' => 'LivingMarkup\Component\A',
'//var' => 'LivingMarkup\Component\Variable',
'//condition' => 'LivingMarkup\Component\Condition',
'//redact' => 'LivingMarkup\Component\Redact'
],
'hooks' => [
'beforeLoad' => 'Executed before onLoad',
'onLoad' => 'Loads object data',
'afterLoad' => 'Executed after onLoad',
'beforeRender' => 'Executed before onLoad',
'onRender' => 'RETURN_CALL',
'afterRender' => 'Executed after onRender',
]
];
Thank you.
After a bit more searching I found a post that addresses this exact question.
https://www.reddit.com/r/PHP/comments/3qqrmz/how_to_handle_config_files_and_default_settings/
To summarize, in case the above link stops working some day, here are some options:
"Bolt CMS does uses a config.yml.dist, which is included with the source code. And the end user can create a config.yml file if one doesn't exist. The config.yml.dist file is part of the official project and acts as the example config file, and should not be modified."
"Your own config.yml file can be tracked in your version control if you wish. Then you can put confidential or environment-specific information into config_local.yml and place that file's name in .gitignore."
"Symfony I use the parameters.yml and config.yml to pass parameters to the objects in DIC."
"Phpunit uses the phpunit.xml.dist file to setup tests."
"Apigen uses .neon or .yaml config files."
"Flysystem asks for config options to be passed directly in the constructor"
"Cakephp has it's own configuration settings, and plugins come with instructions on the keys to add. This asset compress package uses an ini file"
Opus is an option: https://github.com/imarc/opus
I'm trying to set up Chrome Logger to use alongside Laravel as detailed in "Easy Laravel 5", however following the instructions throws errors, and I'm new to Laravel (and not very experienced in PHP), so I'm not sure how to resolve them. We are directed to add a piece of code to the bootstrap/app.php file to use the chrome logger in the book.
The following is a screenshot of the error screen:
The following is the site without the code excerpt:
I tried requiring the chrome.php file using require_once() in the app.php file, but the error still persists. Removing the code excerpt produces the default screen.
This is the code excerpt:
if ($app->environment('local'))
{
$app->configureMonologUsing(function($monolog)
{
$monolog->pushHandler(new \Monolog\Handler\ChromePHPHandler());
});
}
I expected to be able to use the chrome logger, but instead receive the aforementioned error screen.
Add new channel in your configuration file (config/logging.php):
'chrome' => [
'driver' => 'monolog',
'handler' => \Monolog\Handler\ChromePHPHandler::class,
'formatter' => \Monolog\Formatter\ChromePHPFormatter::class
]
Sometimes you may wish to log a message to a channel other than your application's default channel. You may use the channel method on the Log facade to retrieve and log to any channel defined in your configuration file:
Log::channel('chrome')->info('Something happened!');
If you would like to create an on-demand logging stack consisting of multiple channels, you may use the stack method:
Log::stack(['single', 'chrome'])->info('Something happened!');
You can set new channel by default in your .env file
LOG_CHANNEL=chrome
or you can set
LOG_CHANNEL=stack
and change 'stack' list of channels (config/logging.php) like this:
'stack' => [
'driver' => 'stack',
'channels' => ['single', 'chrome'],
'ignore_exceptions' => false
]
After you can use log with all your list of channels
Log::info('General information log');
From Laravel 5.6 documentation.
The configureMonologUsing Method
If you were using the configureMonologUsing method to customize the
Monolog instance for your application, you should now create a custom
Log channel. For more information on how to create custom channels,
check out the full logging documentation.
Looks like we need to be on the earlier version for this to work.
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
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.
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.