Comments (16)
Awesome! Sure, I'll try to get my head around the code base and see if I can do that.
from php.
Wow I was just about to post this:
The three options I can think of:
- Enabling the user to add a php.ini file that will co-live with now.json. When factoring in the user php.ini, we import the directives that are overridable and silently ignore the ones that are not.
- Enabling the user to add a php.ini again at the root level but this time only with supported directives. For example
session.save_handler
,session.save_path
... - Doing 2 but instead of the user including a php.ini, adding php.ini directive to now.json. something like
{
"version": 2,
"builds": [
{
"src": "index.php",
"use": "now-php@canary",
"config": {
"composer": true,
"php.ini": {
"session.save_handler": "redis",
"session.save_path": "tcp://127.0.0.1:6379"
}
}
}
]
}
I'm in favor of the option 3 to keep everything in one place. I think something like this https://github.com/npm/ini can help a lot.
from php.
I think it is a nice one to add to the roadmap, especially for use cases like you just mentioned.
And as always, if you would like, open a PR with this feature 😉
from php.
Hi guys. I like the idea. Could you please elaborate about the configuration?
- Should we put it into the special file? Like php.ini? Should it be in the root folder?
- Or should we put it into the now.json? Only a few override items will be there right?
from php.
In a "normal" *nix environment, you usually extend configuration files by adding multiple files in a conf.d
directory. With this in mind I think it is nice to let the user (as in the developer using this builder) write one (or multiple?) php.ini files and points to the file(s) in now.json. A php.ini file in the same directory as now.json is set as default "zero-config" value.
Also, I don't think it is needed to filter only "supported" directives, as they need to be updated with every extension update. The user probably notices from the build process if they entered some non supported value.
I'm not convinced about putting the directives directly in now.json as this can get quite big fast. A simple .ini
file somewhere in the project seems nicer because it is clear what it does and works like any other php.ini
file.
If you have other opinions and/or insights, please share them 😊
from php.
I'm not convinced about putting the directives directly in now.json as this can get quite big fast. A simple
.ini
file somewhere in the project seems nicer because it is clear what it does and works like any otherphp.ini
file.
This makes total sense. Similar to what docker-compose.yml does with the Dockerfile. it looks neat.
I'm not yet clear though on how a user can add extensions and how this will play out with php.ini. Can you please shed some lights on how the workflow would look like for someone wanting to add an extension, php7-gd
for example.
from php.
I think adding extensions a different problem. As I have understood so far @f3l1x added as much extensions as he could to this builder. Maybe in the future there will be ways to specifically select which ones you want in your builder (or by composer.json?) This can make the resulting lambda smaller (= faster cold starts).
But for now if someone whats to add an extension, I guess they have to create a PR with the binary (which is not safe because there could be anything in it 😐, so maybe a build folder for all the extensions and tools needs to be added to this repository. Also makes updates easier i guess.)
from php.
@ties-v oh I see. I think this a Lambda related problem. Having to supply a binary artifact makes things hard to customize. This is what I miss about Docker 🙃. I did some digging though and found this: https://github.com/awslabs/aws-lambda-container-image-converter . Apparently we can convert a Docker image to a Lambda binary 🤯. This will solve all the customization problems (giving that the input is a Docker file). But I'm still thinking of how this could be mashed up with now-php.
from php.
I have copy&paste already build PHP modules+libs by my self.
https://github.com/juicyfx/now-builders/tree/master/src/php-lib
Still thinking about to take to this repo or separate to solo repository. Maybe others can build a layer from this builded php.
I like awslabs/aws-lambda-container-image-convert, @Malihs, can you please test it how it works?
from php.
@f3l1x have you seen this example? https://github.com/awslabs/aws-lambda-container-image-converter/tree/master/example :
Basically they're using Docker to build a php runtime that would work along with the current lambda OS (amazonlinux:2018.03.0.20190514
). The Docker image runs composer and a handler file. Interestingly enough, instead of using a phpDevServ, they're using Guzzle to manage HTTP.
php.ini might be factored in simply by copying it to /etc/php/
. With something like: COPY path/to/local/php.ini /etc/php7/php.ini
. Here is an example of how I do it https://github.com/malihs/alpine-php7-fpm-apache/blob/master/Dockerfile
The built up image could be run locally (docker should be installed on the machine) .
If you run the built up image with img2lambda
: the runtime get extracted form the docker image and get publish to lambda.
hope this makes it clearer. I was about to reproduce this locally but we decided to steer away from Now Monorepo for the time being.
from php.
Hi everyone, great work on this btw!
I need to be able to set things in php.ini
for my app to work (some of the options don't work with ini_set
).
I personally would love just a simple way to set php.ini
options in now.json
. That way there is only 1 file now is concerned with. All my now-specific env settings and php.ini
options would live there.
from php.
I'm thinking also about some option in now.json
. Can you please show me what kind of php.ini do you need to override? I would like to setup now-php for most cases.
from php.
@mdegrees @calebporzio @ties-v Can you please test it? #17
from php.
{
"version": 2,
"name": "now-php-ini",
"scope": "juicyfx",
"regions": [
"all"
],
"public": true,
"builds": [
{
"src": "*.php",
"use": "now-php@experimental",
"config": {
"php.ini": {
"memory_limit": "128M",
"post_max_size": "32M"
}
}
}
],
"build": {
"env": {
"NOW_PHP_DEBUG": "1"
}
}
}
from php.
@f3l1x working like a charm, thank you!
from php.
Sorry, I didn't get back to you sooner. Thanks @f3l1x - you're the man!
from php.
Related Issues (20)
- could not find driver `pgsql` HOT 3
- Unable to load dynamic library 'mongodb' and 'swoole' when deploying HOT 5
- Error: Exited with 4, Something wrong with the build process, Error: Command "vercel build" exited with 1 HOT 3
- Fatal errors not reported in vercel logs HOT 4
- mongodb module missing in 0.7.0 HOT 1
- Change / Appoint php version HOT 4
- Vercel 0.7.0 + Laravel 10 HOT 2
- the example can't run,what happened? HOT 4
- PHP Built-In Server HTTP error: Error: connect ECONNREFUSED 127.0.0.1:8000 HOT 22
- Can we support php trader
- Can we increase the **max_execution_time** and **post_max_size** here? HOT 2
- Mongo DB is not loaded and returns Class "MongoDB\Driver\Manager" not found
- error: The following Serverless Functions contain an invalid "runtime" when deploying
- Wrong Instruction in README
- Error when deploy it to Vercel "No such file or directory" HOT 5
- php: error while loading shared libraries: libssl.so.10: cannot open shared object file: No such file or directory HOT 1
- Unable to use Sentry
- Auto-deploy production: Vite manifest not found at: /var/task/user/public/build/manifest.json
- Wordpress generate static website
- error shared libraries: libssl.so
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from php.