Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Best strategy for handling custom php.ini files? #32

Open
b00gizm opened this issue Jun 24, 2013 · 11 comments
Open

Best strategy for handling custom php.ini files? #32

b00gizm opened this issue Jun 24, 2013 · 11 comments

Comments

@b00gizm
Copy link
Contributor

b00gizm commented Jun 24, 2013

Is there a way to import a custom php.ini file instead of the default one?

I found a more or less decent workaround for my virtual hosts, by providing all custom settings as FastCGI params, but that does not apply to the CLI.

I thought about an additional *.ini file to parse the missing settings from, but this seems to me like a dirty hack.

So what is the "official way" to handle custom php.ini settings?

@mattheath
Copy link
Owner

@b00gizm Currently there is no official way to set a custom .ini file unfortunately, though I would welcome suggestions. The problem stems from PHP only allowing a single php.ini file (or a set) to be parsed for a specific version of PHP, so per project settings are not possible.

The PHP project manifest then allows a version of PHP to be defined per project, which then includes the appropriate versions and sets up the services. Puppet only allows a resource to be defined once, so this is done by moving the resource definition to the php version manifest files and including one of these each time (we can include a class multiple times). Unfortunately, this then means settings can't be defined on a project basis.

So, tl;dr is that we could change the module to allow a custom php ini file as long as the PHP version was defined at a higher scope than a project and only defined once, but defining on a per project basis precludes this. I'm not sure if there is some crazy puppetry which could be done to get around the problem!

@b00gizm
Copy link
Contributor Author

b00gizm commented Jun 26, 2013

@mattheath I wouldn't say that a per-project php.ini is necessary for now. It would be sufficient to have control over the php.ini for a specific PHP version. It's not a totally satisfying solution, but that's due to PHP's own limitations concerning the php.ini. But yeah, at least it's something ;)

@mattheath
Copy link
Owner

Yeah PHP is never going to allow per project .ini files, what I meant was that allowing a custom .ini file will mean PHP will have to be declared at a higher level - eg. site.pp or in a custom class within your boxen. With the current module layout it won't be possible to use the PHP project class at all.

@b00gizm
Copy link
Contributor Author

b00gizm commented Jun 27, 2013

That's what I'm talking about :)

Declaring the php.ini at a higher level would be sufficient. What about:

define php::version(
  $ensure    = 'installed',
  $version   = $name,
  $php_ini   = undef
) {
 ...
}

You could still use the shorthand include php::version { '5.4.10' }, but also add the path to a custom php.ini.

@b00gizm
Copy link
Contributor Author

b00gizm commented Jul 15, 2013

Any progress on that? :)

@mattheath
Copy link
Owner

Sorry, I've not had a chance to look - pull requests welcome! ;)

@EugenMayer
Copy link
Contributor

i worked on that and implemented it here https://github.com/EugenMayer/puppet-php/commit/3ed20dae3576f78b051904352e6004de81efb29d .. but still that wont help, as i stumbled uppon.

There is no way to deploy your own php::version {'own 5.3.23': phpini_template=> "...."} since you would get a dublicate error.

In addition, php::version is wrapped by php_XXXX classes and you need to proxy pass those values. Currently, iam not sure which approach to take, but for now, this holds for nearly all boxes recipes ... they are all very limited and bascially build to be forked and replicated

webflo pushed a commit to webflo/puppet-php that referenced this issue May 5, 2014
@nomasprime
Copy link
Contributor

A temporary fix, for me at least, would be to stop this module overwriting php.ini every time boxen is run. Does anybody know how to do this?

@webflo
Copy link
Contributor

webflo commented Jul 21, 2014

Put your own php.ini in /opt/boxen/config/php/[version]/conf.d all ini files in conf.d are automatically included and override previous defined config parameter. You don´t need a complete php.ini file, just override the parameters you need.

@nomasprime
Copy link
Contributor

@webflo I was thinking of using puppet to override the file with my own but didn't realise you could do this. Cleaner solution, thanks.

@clempat
Copy link

clempat commented Oct 1, 2014

For the override solution using an personalised template:

$mainVersion = '5.4.29'
File <| title == "${php::config::configdir}/${mainVersion}/php.ini" |> {
        content => template('base/php.ini.erb')
}

with module base and file php.ini.erb

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants