I'm writing this up from memory, so errors may appear.
This has been updated to use SHA256 certificates.
- Go to http://www.startssl.com/
- Click on 'Control Panel'
#!/usr/bin/env bash | |
# print usage | |
DOMAIN=$1 | |
if [ -z "$1" ]; then | |
echo "USAGE: $0 tld" | |
echo "" | |
echo "This will generate a non-secure self-signed wildcard certificate for " | |
echo "a given development tld." | |
echo "This should only be used in a development environment." |
UseCanonicalName Off | |
<VirtualHost *:80> | |
ServerAdmin [email protected] | |
ServerAlias *.example.com | |
VirtualDocumentRoot /var/www/%1/public | |
DirectoryIndex index.php index.htm index.html | |
<Directory /var/www/*/public/> | |
AllowOverride All | |
</Directory> |
I'm writing this up from memory, so errors may appear.
This has been updated to use SHA256 certificates.
One of the best ways to reduce complexity (read: stress) in web development is to minimize the differences between your development and production environments. After being frustrated by attempts to unify the approach to SSL on my local machine and in production, I searched for a workflow that would make the protocol invisible to me between all environments.
Most workflows make the following compromises:
Use HTTPS in production but HTTP locally. This is annoying because it makes the environments inconsistent, and the protocol choices leak up into the stack. For example, your web application needs to understand the underlying protocol when using the secure
flag for cookies. If you don't get this right, your HTTP development server won't be able to read the cookies it writes, or worse, your HTTPS production server could pass sensitive cookies over an insecure connection.
Use production SSL certificates locally. This is annoying
Having read a number of guides on using SSL with MAMP I still couldn't get things working properly. This is my guide which takes ideas from a number of resources. As with the guides I'd previously read this may or may not work for you but either way I hope it helps.
I imagine you can generate a wildcard certficate for all local sites but this didn't work for me so I generated a certificate for each local site individually. This method uses the subjectAltName field as this is required since Chrome 58.
Create the following file in your user folder and save as server.csr.cnf. Remember to change your Country (C), State (ST), Location (L), Organisation (O), Oganisational Unit (OU), Email Address( emailAddress) and Common Name (CN). For the common name I matched with my local site name as defined in my hosts file.
Translations: Korean (by Yongwoo Lee)
Laravel has a powerful Inversion of Control (IoC) / Dependency Injection (DI) Container. Unfortunately the official documentation doesn't cover all of the available functionality, so I decided to experiment with it and document it for myself. The following is based on Laravel 5.4.26 - other versions may vary.
I won't attempt to explain the principles behind DI / IoC here - if you're not familiar with them you might want to read What is Dependency Injection? by Fabien Potencier (creator of the Symfony framework).
<?php | |
namespace App\Extensions; | |
// we have an Eloquent model that allows using the session table with the querybuilder methods and eloquent fluent interface- read only! | |
use App\Session; | |
// use the provided database session handler to avoid too much duplicated effort. | |
use Illuminate\Session\DatabaseSessionHandler; | |
class AppDatabaseSessionHandler extends DatabaseSessionHandler |
tldr: the function at the end of this gist will give you a random array element
Figuring out how to get a random array element will give a better understanding of how PHP works, as well as how arrays work in general.
Lets start with this code:
$numbers = [1, 2, 3, 4, 5];