php support?

I was thinking of these packages:

apt-get -y install \
php7.0-fpm \
php7.0-mysql \
php7.0-curl \
php7.0-gd \
php7.0-intl \
php-pear \
php-imagick \
php7.0-imap \
php7.0-mcrypt \
php-memcache \
php7.0-pspell \
php7.0-recode \
php7.0-sqlite3 \
php7.0-tidy \
php7.0-xmlrpc \
php7.0-xsl \
php7.0-mbstring \
php-gettext

Hi,

The main issue is that php will want to install the Apache server (if I remember correctly). Coronium runs on nginx. While these might work fine together, its going to increase your overhead.

The best way would be to create an nginx configuration to proxy calls to FPM. I haven’t done it in awhile, but I can take a look in the next couple of days.

-dev

Hi,

Are you wanting the php instance to be publicly accessible, or are you only planning on proxying it through the Coronium Core Network module?

-dev

I don’t need it public. It is mainly for a script that sends a call to the OneSignal api and creates a job on the server. Which then sends another push after 24 hours and then deletes a mongo record :slight_smile:

It was a custom job type I created for the old coronium cloud that basically starts a challenge, sends a notification to both users, and creates a 24 hour timer. If a user takes longer than 24 hours it deletes the game record and notifies them the game has ended. Or if they do respond in time, I had another script that deletes the old job, creates a new one, and a notification that it was the other user’s turn. If that makes any sense lol

Hi,

I was looking through the One Signal documentation, and you can actually call all the methods to One Signal using their web based API (and skip the PHP altogether), using the Coronium Network module, it’s just a simple JSON request and they actually include examples, you just need to convert the JSON syntax to Lua table stylings, which is pretty easy:

For example, a Coronium server-side API might look like:

local api = core.api() function api.createNotification(input) local data = { app\_id = "5eb5a37e-b458-11e3-ac11-000c2940e62c", included\_segments = { "All" }, contents = { en = "English Message" }, data = { foo = "bar" } } local resp, err = core.network.postJson("https://onesignal.com/api/v1/notifications", data, { ["Content-Type"] = "application/json;charset=utf-8", ["Authorization"] = "Basic NGEwMGZmMjItY2NkNy0xMWUzLTk5ZDUtMDAwYzI5NDBlNjJj" }) if not resp then core.log(err) end core.log(resp) end return api

The above is the conversion of the https://documentation.onesignal.com/reference#section-send-to-all-subscribers-create-notification using the JSON tab.

If you don’t want to convert the JSON, you can do this instead:

local api = core.api() function api.createNotification(input) local data = --this is a JSON object string [[{ "app\_id": "5eb5a37e-b458-11e3-ac11-000c2940e62c", "included\_segments": ["Active Users"], "data": {"foo": "bar"}, "contents": {"en": "English Message"} }]] data = core.json.decode(data) local resp, err = core.network.postJson("https://onesignal.com/api/v1/notifications", data, { ["Content-Type"] = "application/json;charset=utf-8", ["Authorization"] = "Basic NGEwMGZmMjItY2NkNy0xMWUzLTk5ZDUtMDAwYzI5NDBlNjJj" }) if not resp then core.log(err) end core.log(resp) end return api

In both cases it’s using the server-side network.postJson method.

I have a PHP addon pretty much done, but it would not be officially supported, and you’ll still need to use the Coronium Network module to call to the PHP, so in essence doubling the work, and putting more stress on the server.

-dev

Yes, you’re right I could use the web based API. My only question now is, how would I run a shell_exec type command from a lua script to set up my job to run another lua file with parameters 24 hours from the time the push is sent? I was using php to do some mongo db checks, then sending another push with something like this:

exec(“echo ‘php /home/coronium/php/push.php “.$user.” “.$device_token1.” “.$device_token2.”’ | at now + 24 hours”);

Hi,

I have a PHP installer add-on done, but it requires Coronium Core 2.4.1 which will be announced shortly.

You can be the tester and see if it does what you need. :wink:

-dev

Hi,

You can update to 2.4.1 now, and then I’ll point you toward the PHP add-on.

Assuming you’re running 2.4.0, https://develephant.github.io/coronium-core-docs/server/updates/#240-to-241

-dev

Ok, I’ll take a test run :)