Generate a Random Key in PHP
The following code will generate a randomized string in PHP
bin2hex(random_bytes(16))
Where 16 is number of bytes which will generate a 32 character string.
The following code will generate a randomized string in PHP
bin2hex(random_bytes(16))
Where 16 is number of bytes which will generate a 32 character string.
Steps to replace master with a different branch.
I need to do this way too often.
git checkout newbranch git merge -s ours master git checkout master git merge newbranch
A docker-compose.yml
template that I use for development
version: "3" services: api: build: context: ./api dockerfile: Dockerfile.dev container_name: ${APP_NAME}-api ports: - 8402:443 environment: APP_BASE_URL: https://${APP_HOST}:8402 APP_ENV: development DB_NAME: DB_USER: DB_PASS: DB_HOST: db SESSION_COOKIE_DOMAIN: SESSION_NAME: SESSION_EXPIRY: #dev only PHP_IDE_CONFIG: serverName=${APP_HOST} XDEBUG_CONFIG: "remote_host=host.docker.internal idekey=${APP_HOST}" XDEBUG_IDEKEY: ${APP_HOST} volumes: - ./api:/var/www/ db: image: mysql:8.0.13 container_name: ${APP_NAME}-db ports: - 8404:3306 volumes: - ${APP_NAME}-db-data:/var/lib/mysql - ./db/dump.sql:/docker-entrypoint-initdb.d/dump.sql - ./mysql/my.cnf:/etc/mysql/conf.d/my.cnf environment: MYSQL_ROOT_PASSWORD: MYSQL_DATABASE: MYSQL_USER: MYSQL_PASSWORD: volumes: db-data: name: ${APP_NAME}-db-data
A .env
file is also required.
# for dev environment only APP_HOST=project-name.local.example.dev APP_NAME=project-name
Create a new database and user that has all permissions to the new database
CREATE DATABASE mydatabase CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; CREATE USER 'jsmith'@'%' IDENTIFIED BY 'password'; GRANT ALL ON mydatabase.* TO 'jsmith'@'%';