Cannot use php in glitch

I’ve been trying to use PHP in glitch, I’ve searched about the topic and some say yes and some say no, I’ve also seen some PHP projects in glitch, but I’m not able to reproduce them, when I upload a php file as example, it goes to assets and cannot get imported to my website.

Kind of off-topic but yes, I know it’s a good namesnipe.

1 Like

You need a way to tell glitch which is your starting file, this is normally done in package.json, so in the examples look for that or a similar kind of file.

1 Like

@mishavee is correct in that you need some way to tell Glitch what to do when your project starts up. The existing PHP examples largely use a glitch.json file which is an alternative to package.json but for non-Node projects. Additionally you need some sort of server to run your PHP code, since Glitch assumes that Node is your server. Most of the examples I’ve worked with include specific Apache web server information in the project, so starting out by Remixing one of those projects makes sure you’ve got those additional required files - otherwise Glitch doesn’t know what to do.

I’d suggest Remixing one of the projects in https://glitch.com/search?q=php&activeFilter=project to give you a solid starting point.

Hope this helps!

4 Likes

@cori We really don’t need to install Apache and PHP?

They’re already installed in the container, which is largely just a little Ubuntu server:

app@hip-crab:~ 13:39 
$ which apache2
/usr/sbin/apache2

app@hip-crab:~ 13:39 
$ which php
/usr/bin/php

The projects I pointed to for remixing already have some of the boilerplate config done, that’s all.

1 Like

@cori is it possible to get a newer PHP version? There’s PHP 7.0.something installed in the container, which is no longer supported by the PHP core team. I want to get Kirby CMS up and running on Glitch to use it as a starting point for our users, but we require at least PHP 7.1.

1 Like

Hey @bastianallgeier, welcome to the Glitch forum!

Unfortunately when it comes to PHP we’re just using the version that comes with the Ubuntu release the containers are built on. We plan to update the OS in the containers sometime in the future which I believe will get us on a slightly newer version, but I don’t know when we’re likely to get to that work, or barring that to updating to a “non-standard” version inside the current container.

Sorry for the bother!

1 Like

Thank you for the quick reply, @cori! I understand that it’s getting a lot more complex when you have to leave the default version that’s being shipped with Ubuntu. Weird that they carry a version around that has reached its end of life and no longer receives security updates.

I will wait and keep my fingers crossed :slight_smile: