Using SSL with the PHP builtin server

Hello!

I’m trying to open my slim application via HTTPS. How do you achieve this?

By default, you have to start each individual slim application manually with:

php -S localhost: 8080 -t public public/index.php

This command starts the PHP built-in server, but only with HTTP.
I know that PHP built-in server does not support SSL.

I use Apache (XAMPP) in my local development environment and this solutions works quite good. The problem is, I have 10+ projects and don’t want to maintain so many HTTP+HTTPS ports.
https://gist.github.com/odan/4d7475f15bddec50e3092854b85a3d73#https--ssl-setup

How do you handle many sites with the Slim framework and how to handle it with SSL?

This is a server configuration issue. Slim doesn’t care what web server you use.

You upload Slim to a web server and if you configured it to run with Ssl Great. if not… Great…

As for your local development; that’s again purely up to you. I personally do not ever use SSL locally b/c I dont feel the need to encrypt my traffic over my localhost interface.

I’m just talking about the local development environment

In this special case I have to check if there is a real SSL connection and test how the application behaves under these conditions.

But anyway, how do you switch between multiple different (Slim) projects (in your local development environment)? Do you always stop and start the PHP built-in server?

For local development using XAMPP, first go to xampp\apache\conf\extra and edit the httpd-vhosts.conf file.
Example configuration:

<VirtualHost *:80>
ServerName myproject.local
DocumentRoot “C:/xampp/htdocs/myproject”
<Directory “C:/xampp/htdocs/myproject”>
AllowOverride All
Require all granted

After editing httpd-vhosts.conf you must restart Apache.

Next you need to edit the Windows hosts file, I suggest using HostsMan (freeware) for a easy way to do so.
You just add myproject.local and save it, you will then have access to myproject.local in your browser.

Hopefully I explained well enough to get you going.

I use Vagrant with virtual box to manage a virtual host for my projects.