I found a tutorial from 2015 where someone worked out how to do this, but Slim has added a lot of dependencies and wants to read outside of the folder for a file (…/vendor/autoload.php).
I’m trying to run this on my hosting company (shared web host). I do not (and have no desire to) have Apache, PHP and MySQL installed on my MacBook Pro. I’m looking for a solution, where I can download a folder with everything in it, upload it to my server, write index.php and setup a .htaccess file and start coding my APIs. I have no desire to do devops.
Is there a Walkthrough for installing Slim on a server where you cannot run Composer and where you don’t have to be able to run it “Local”?
If I have to use yet another package manager I’m going to go insane. I may as well just run node.js and call it a day. I’d rather do this in PHP.
Please tell me there is a solution for this.
The thing is… you don’t need to (and should not) install composer on your productive webserver.
Slim also works on a shared hosting, so you don’t have to do any DevOps stuff at all.
IMHO composer is a must for modern PHP applications, because of all the dependencies and PSR-4 autoloader etc… Even for frontend stuff you need npm and webpack today (only on your local dev machine).
The solution is:
Don’t install composer (and node.js / npm) on your productive webserver
- Install a local development environment (e.g. XAMPP) + composer + PhpStorm.
- Build an optimized artifact that you can deploy on your productive webserver.
Just a small remark to all what odan said. You don’t even have to install any apache server or the whole xampp package. I suppose that makes your discouraged. Php just for a development purpose, delivers built-in server, so by simple:
$ php -S localhost:8080 -t public/ (from within your app root dir)
$ php -S localhost:8080 (from within your public dir)
You can trigger your page with the browser.
And the last word. Don’t avoid composer. This is one of the simplest and the most friendly tools you can imagine. One can write Phd thesis on that subject.
I went ahead and installed Composer. So we can close this topic. Now to get my hosting server’s FTP issues solved (which they deny exist… sad…)
It is best to use Composer to install Slim. It is easier that way. FTP method had a lot of issues for me as well. I tried installing it through FTP on my PHP host but it didn’t work for some reason. Whereas I can install other packages and frameworks fine.