Where to add guard config information of zfc-rbac? - zend-framework

I am following this guide to add Zfc-Rbac in my application. But I can't figure out where to put this configuration information.
Application\config\application.config.files
or Application\modules\modulename\config\module.config.php

You can also put it in a global config file, ie application/config/autoload/zfcrbac.global.php

Either in application/module or application/vendor, place the config inside the ModuleName/config/module.config.php
Also make sure you have added the ZfcRbac to the application module list
'modules' => array(
'Application',
'ZfcRbac',
'DoctrineModule',
'DoctrineORMModule'

Related

Call to undefined method Illuminate\Html\FormFacade::open()

I am building a web app with Laravel and I get this error once I run the application:
Call to undefined method Illuminate\Html\FormFacade::open()
Some mention to use "laravelcollective/html": "5.1.*" as "illuminate/html": "^5.0" no longer uses Form. However, in both cases I get the error message above. Can you advise me how to solve this problem.
Be sure your composer.json file uses "laravelcollective/html": "^5.0#dev", as the illuminate version is no longer supported.
Be sure to add Collective\Html\HtmlServiceProvider::class, in your config/app.php file as a providor, as well as the aliases:
'HTML' => Collective\Html\HtmlFacade::class,
'Form' => Collective\Html\FormFacade::class,

Using AdditionalConfiguration.php for many TYPO3 Installation?

I use one global AdditionalConfiguration.php for serveral TYPO3 Installation. I just symlink this file.
AdditionalConfiguration.php -> /global/typo3_every_instance/typo3conf/AdditionalConfiguration.php
Now in this AdditionalConfiguration.php I can enforce the use of rsa for every TYPO3 Instance:
$GLOBALS['TYPO3_CONF_VARS']['BE']['loginSecurityLevel'] = 'rsa';
I too have a configuration for maxFileSize there:
$GLOBALS['TYPO3_CONF_VARS']['BE']['maxFileSize'] = '20240'
But on some installation I want to have a bigger maxFileSize, so I have this in my LocalConfiguration.php:
'BE' => array('maxFileSize' => 150000)
Now I changed the AdditionalConfiguration.php to:
/* if not set in LocalConfiguration maxFileSize has default value */
if($GLOBALS['TYPO3_CONF_VARS']['BE']['maxFileSize'] == '10240'){
$GLOBALS['TYPO3_CONF_VARS']['BE']['maxFileSize'] = '20280'; // 10MB
}
What to you think about this?
what happens if the default value changes for some reason?
I do not know whether the AdditionalConfiguration.php is read before or after the
LocalConfiguration.php?
If your LocalConfiguration.php is read after AdditionalConfiguration.php
just set the new value.
if it's the other way round you can try following code
in LocalConfiguration
define("FILESIZE",'150000');
in AdditionalConfiguration
$GLOBALS['TYPO3_CONF_VARS']['BE']['maxFileSize'] = defined("FILESIZE")?FILESIZE:'20240'
Hope it helps
In my opinion the way to go is the TYPO3 Application Context. You can set single values inside an if in your AdditionalConfiguration.php or even just load a specific one for each context, e.g. AdditionalConfigurationTesting.php.
Here is a great article how to set and use this: https://usetypo3.com/application-context.html
In the future in modern docker environments its probably more the way to go with .env files - filled with your local settings.

Cakephp /Config/email.php into a Plugin

Hi i have a plugin called Contact and into it i have
/Config/email.php file.
Cake seems not to load that file.
In my main bootstrap.php file i tried this:
CakePlugin::loadAll(array('Contact'=>array('bootstrap'=>true, 'email'=>true, 'routes'=>true)));
the bootstrap.php and routes.php file are loaded, the email.php no
Thanks
That's not how CakePlugin::load/loadAll() works, there is no email option, only bootstrap, routes and ignoreMissing.
Check the coobook and the API documentation
http://book.cakephp.org/2.0/en/plugins.html#advanced-bootstrapping
http://api.cakephp.org/2.4/class-CakePlugin.html#_load
If you like to load more than one bootstrap file for a plugin. You can specify an array of files for the bootstrap configuration key...
So something like this should work for you:
CakePlugin::loadAll(array(
'Contact' => array(
'bootstrap' => array(
'bootstrap',
'email'
),
'routes'=>true
)
));
That would load the files /Plugin/Contact/Config/bootstrap.php and /Plugin/Contact/Config/email.php.
However it won't work in case that file contains an EmailConfig class definition and your app also loads the app/Config/email.php file where such a class definition already exists. In that case you should choose another way to define your email configuration settings.

How to handle Zend Framework End User INI/Config settings

I have searched and searched for this but I think my terminology isn't correct as it keeps giving me the application settings for the zend site rather than an application settings for the End User.
I'd like to have a config.ini type file that the end user can edit values in. I'd like it to be ONLY the settings I wish them to see and to be able to create the value names as I think would make sense to them. So it would be something like
[General]
SiteName=MySite
ShowResources=TRUE
[Database]
Server=myServer
databasepath=mydbpath
...
So my two questions.
1. What is this type of file called because when I search application settinsg, I get the ZF application settings not one for an end user (presumably)
What is the best way to handle this type of file?
Thanks
In your bootstrap add:
protected function _initConfig()
{
$config = new Zend_Config_Ini(APPLICATION_PATH.'/configs/config.ini');
Zend_Registry::set('config', $config);
return $config;
}
replace config.ini with whatever you want the filename to be.
You can then access this config object anywhere in your application either as an application resource or through the registry (Zend_Registry::get('config')). So to get the SiteName from your example:
$config = Zend_Registry::get('config');
echo $config->General->SiteName;
For things like database settings, you'll want to access these in the bootstrap so you can use them to setup other resources. I would recommend you don't try and include database settings in your application.ini as well, instead manually setup the DB resource by adding another bootstrap method:
protected function _initDb()
{
$this->bootstrap('config');
$config = $this->getResource('config');
$db = Zend_Db::factory('Pdo_Mysql', array(
'host' => $config->Database->Server,
'username' => $config->Database->Username,
'password' => $config->Database->Password,
'dbname' => $config->Database->Dbname
));
return $db;
}
To explain this some more, $this->bootstrap('config'); ensures the config resource is loaded first. $this->getResource('config'); returns the config resource (the one created by the _initConfig() method). It then uses the data from this object to create the DB connection.
It's an INI file, which you can read and write via Zend_Config.
ZF has no concept of "user settings" -- users are defined by you, not by the framework.
Apps usually store user configs in a database, but that's totally up to you. You could store a directory of INI files instead. Either way, you have to do the implementation yourself.
Edit: Given that you have a ZF app that you're distributing to the customer, and they're only ever going to connect to one database with it, that changes things significantly. (I thought you originally meant that you'd have one instance of the app simultaneously connecting to multiple databases.)
In your case, I would use the standard ZF application/configs/application.ini file for your application's "internal" settings. Then, I'd have a separate local.ini (or whatever) in that same application/configs directory, which contains only those settings that you want the customer editing. Distribute a skeleton local.ini file with the app, that has instructions right in it, something like this:
; Remove the comment from this line.
;configured = 1
; You need to put your database credentials in here.
db_host = "PUT YOUR DATABASE SERVER NAME HERE"
db_user = "PUT YOUR DATABASE USERNAME HERE"
db_pass = "PUT YOUR DATABASE PASSWORD HERE"
Then just load the local.ini file via Zend_Config. I'd also add a check to your index controller's init method that checks to see if you're properly configured:
$localConfig = Zend_Registry::get('local_config'); // or wherever you put it
if (!$localConfig->configured) {
$this->_helper->redirector('config', 'error');
}
And then make a error/config view that says:
You didn't read the instructions. Go do that now.
Note there's nothing stopping the customer from editing anything they want, but this makes a logical separation and makes it harder to accidentally screw something up.

Configuring form_path in Catalyst::Controller::Formbuilder

Using the Catalyst::Controller::FormBuilder module to handle forms in a Catalyst application.
The documentation says you can set the form_path like this:
form_path => File::Spec->catfile( $c->config->{home}, 'root', 'forms' ),
But the call to config() in my application is at the top level of the base module. Therefore, $c is undefined. So I can't call $c->config->{home}.
What is the proper way to configure form_path please?
You should be able to access configuration values that have already been set from your application's main module using the __PACKAGE__->config hash. Example: __PACKAGE__->config->{home} or __PACKAGE__->config->{'Controller::FormBuilder'}->{form_path}.
If you're trying to set the FormBuilder configuration in your applications main module, you should be able to use the code provided in the documentation and just replace $c->config->{home} with __PACKAGE__->config->{home}. I think they might have even made a mistake by not doing it this way, but I'm not sure.