Skip to content
This repository has been archived by the owner on Jan 25, 2023. It is now read-only.

better php support in build image #124

Closed
fool opened this issue Jan 10, 2018 · 8 comments
Closed

better php support in build image #124

fool opened this issue Jan 10, 2018 · 8 comments
Labels
help wanted type: feature code contributing to the implementation of a feature and/or user facing functionality

Comments

@fool
Copy link
Contributor

fool commented Jan 10, 2018

Ported from the feature requests listing, seems to belong here instead:

Summary

We should support more php version the way we support node versions (with an easy config flag) and probably also some PHP dependency manager.

Details

We currently support an ancient (but stock for our ubuntu release) php version, 5.5. Via phpbrew we kiiind of support php 5.6. It's not something anyone would figure out how to use without some guidance, but it is at least possible

The current version of PHP is 7.2 and while this is a fairly recent release, it's also a major change (there was no production-quality php 6 release).

We should also support a dependency manager like Composer (think Ruby bundler for php)

Note: there are very few PHP users on our platform, so we are unlikely to pursue this - great opportunity for a contribution if it's something you need!

@minthemiddle
Copy link

minthemiddle commented Jan 12, 2018

Just a question: How do you know you have few PHP users?

There are many static page generators (and some even somewhat influential, like Sculpin and Jigsaw), and people have to build locally and will only deploy static pages. I use Jigsaw which is popular in the Laravel world, and though it might be possible to use continuous deployment with php5.5 it would be so much easier and fast with php7.0+. This is why I think there are virtually no PHP users right now, because noone still uses 5.5.

@sugizo
Copy link

sugizo commented Jan 12, 2018

did you manage to make it work for jigsaw? several days ago tested it, recevie an error in build log, send an email to netlify support, they just told that the composer installed in their dockerfile, but can't be used
the build script that i've tested:
netlify.toml
[build]
command = "composer require tightenco/jigsaw && ./vendor/bin/jigsaw build"
publish = "/build_local"

return an error in build log:
/opt/build/build.sh: line 468: composer: command not found

tried another way
netlify.toml
[build]
command = "sudo apt update && sudo apt install -y composer php && composer require tightenco/jigsaw && ./vendor/bin/jigsaw build"
publish = "/build_local"

return an error in build log:
sudo: no tty present and no askpass program specified

forgot to tell, the same source (jigsaw) works in another cicd hosted
is there a way to make php static generator work in netlify?

@fool
Copy link
Contributor Author

fool commented Jan 12, 2018

@minthemiddle this thread will be a great way to tell if I'm wrong :) I am already surprised by the amount of engagement!

However I have done some formal surveys of build commands our customers use and the php-based frameworks and commands are very rare, is why I made the statement - it is objectively true.

Do I want to support php less? absolutely not! Will there be substantial engineering effort spent on it by Netlify staff vs ruby/node? Probably not in the immediate future - hence my request for PR's ;)

@fool
Copy link
Contributor Author

fool commented Jan 12, 2018

@sugizo what you reported is not what our team said in that support ticket - they just said you can't use sudo, and composer is already supposed to be there - but I am not sure it is. I've reopened your case and we'll take another shot.

Since you didn't respond to our last suggestion in that thread, we assumed you got something working. A "try this to see if you can figure it out" is always open to a response of "I couldn't" if you need more help :)

@minthemiddle
Copy link

@fool Thanks for clarification. Will look into how to possibly tweak the build image and might be able to contribute…

@sugizo
Copy link

sugizo commented Jan 12, 2018

pardon, forgot to replied gerald's advice last time, the status of jigsaw's built is published right now, after follow chris advice with:
netlify.toml
[build]
command = "source /opt/buildhome/.phpbrew/bashrc && phpbrew switch 5.6.32 && /opt/buildhome/.phpbrew/bin/composer require tightenco/jigsaw && ./vendor/bin/jigsaw build"
publish = "/build_local"

the different with my previous posted is, i didn't know the full path of composer so that the status is command not found, but now is work well, thx 4 quick respond

@fool
Copy link
Contributor Author

fool commented Jan 12, 2018

@depadiernos could you write this up as a FAQ? It's not really "frequent" but I'd like to get it doc'd somewhere and we talked through this together. Issue will stay open until we improve support but right now it's impossible for someone who doesn't find this thread or ask support how to get composer or php version selection working

@minthemiddle
Copy link

minthemiddle commented Jan 14, 2018

Here is my write-up of how to use continuous deployment with Jigsaw (Laravel based):

https://github.com/minthemiddle/netlify-php-cdci-jigsaw

Studying the build image, I really wonder why Netlify installs PHP5 and does not use PHP72 via apt:

sudo add-apt-repository ppa:ondrej/php
sudo apt-get update
sudo apt-get install php7.2-cli

(Source: https://www.colinodell.com/blog/201711/installing-php-72)

PHP7 is largely downward compatible and a lot safer and faster than PHP56.

brycekahle added a commit that referenced this issue Feb 6, 2018
Remove php 5.5, add 7.2.2
Automatically install composer dependencies and cache them.

Fixes #124
Fixes #102

Co-Authored-By: Arnaud Ligny <[email protected]>
@verythorough verythorough added the type: feature code contributing to the implementation of a feature and/or user facing functionality label Feb 23, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
help wanted type: feature code contributing to the implementation of a feature and/or user facing functionality
Projects
None yet
Development

No branches or pull requests

4 participants