Generate a Secure Password in PHP (2025 Version)

Generating strong passwords is a fundamental element of application security. A strong password should be long and contain a combination of different character types. An outdated approach, often seen in old tutorials, used functions like rand() and srand(). These are not considered secure enough for cryptographic tasks. Here is a modern and secure solution for generating passwords in PHP. The Modern Function: generateStrongPassword This new function uses random_int(), which is designed in PHP to generate cryptographically secure random integers. It is also much more flexible and readable. ...

July 8, 2025 · 3 min · 613 words · oxomichael

Microsoft Edge workaround with Virtualbox (vagrant) and local domain

Due to network isolation in Windows 10 (is it a bug ?). Edge can’t access domain in VirtualBox network, so we use regedit.exe Looks for key registry name as *NdisDeviceType of your virtual network card (from VirtualBox), and change the value to “0” (value is set to one by default), and reboot. To find the key, see something like that in the registry Computer\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Class\{4d36e972-e325-11ce-bfc1-08002be10318}\00XX. The change will make your network card in active networks, as a “Public” or “Unidentified” network. ...

October 6, 2018 · 1 min · 80 words · oxomichael

Configure Nextcloud with a reverse proxy (Nginx)

How to configure Nextcloud with a reverse proxy and add security headers correctly. NextCloud with Apache Our Nextcloud instance will be installed with Apache/PHP-FPM. In your vhost configuration or in your .htaccess file, comment out the following lines: <IfModule mod_env.c> # Add security and privacy related headers # Header set X-Content-Type-Options "nosniff" # Header set X-XSS-Protection "1; mode=block" # Header set X-Robots-Tag "none" # Header set X-Download-Options "noopen" # Header set X-Permitted-Cross-Domain-Policies "none" SetEnv modHeadersAvailable true </IfModule> Configure Nginx Configure a standard reverse proxy. ...

March 18, 2018 · 1 min · 159 words · oxomichael

Vagrant multi-machine

The purpose is to have several VM to reproduct production environment, simulate network failure. We start simply with a web machine and an external database (and specific disk size for that) Install vagrant plugins vagrant plugin install vagrant-vbguest vagrant plugin install vagrant-disksize Create your multi machine environment cd {yourdir}/workspace/envdev/ mkdir my-multi-machine cd my-multi-machine vagrant init ... Edit your Vagrantfile Vagrant.configure("2") do |config| # WEB config.vm.define "web", primary: true do |web| web.vm.box = "debian/stretch64" web.vm.box_check_update = false web.vm.network "private_network", ip: "192.168.33.101" web.vm.synced_folder ".", "/vagrant", owner: "vagrant", group: "vagrant", type: "virtualbox" web.vm.synced_folder "../../", "/home/vhosts", owner: "vagrant", group: "vagrant", type: "virtualbox" web.vm.provider "virtualbox" do |vb| vb.customize ["modifyvm", :id, "--name", "web"] vb.customize ["modifyvm", :id, "--memory", "512"] vb.customize ["modifyvm", :id, "--natdnshostresolver1", "on"] vb.customize ["modifyvm", :id, "--natdnsproxy1", "on"] end end # DB config.vm.define "db" do |db| db.vm.box = "debian/stretch64" db.disksize.size = "30GB" db.vm.box_check_update = false db.vm.network "private_network", ip: "192.168.33.102" db.vm.synced_folder ".", "/vagrant", owner: "vagrant", group: "vagrant", type: "virtualbox" db.vm.provider "virtualbox" do |vb| vb.customize ["modifyvm", :id, "--name", "db"] vb.customize ["modifyvm", :id, "--memory", "512"] vb.customize ["modifyvm", :id, "--natdnshostresolver1", "on"] vb.customize ["modifyvm", :id, "--natdnsproxy1", "on"] end end end “web” machine is the primary. When you vagrant ssh, you enter in it automatically. So to go in db, enter vagrant ssh db ...

December 11, 2017 · 2 min · 240 words · oxomichael

Symfony Console

In every project we always need some task to be executed in console, so you have a web app in php, continue in php and use symfony/console Installation $ composer require symfony/console ## Creating a New Command To create a new command, we need to make sure our file will be executable. In order to do that, let’s create a console file in the root of our project. This file will be our command manager. ...

December 10, 2017 · 6 min · 1273 words · oxomichael

Using inotify

Description inotify allows you to add a watch descriptor to a file and send notifications to the system when an event affects that file. As a reminder, in the UNIX world, a file can represent a simple file, but also a directory, a device, a link, etc. The main events that can be monitored are: IN_ACCESS: the file is read; IN_MODIFY: the file is modified; IN_ATTRIB: the file attributes are modified; IN_OPEN: the file is opened; IN_CLOSE_WRITE: the file is closed after being opened for writing; IN_CLOSE_NOWRITE: the file is closed after being opened for reading; IN_MOVED_FROM / IN_MOVED_TO: the file has been moved or renamed; IN_DELETE_SELF: the file has been deleted; IN_DELETE: a file has been deleted in the watched directory; IN_CREATE: a file has been created in the watched directory. Incron To install incron: ...

December 5, 2017 · 3 min · 477 words · oxomichael

My Dev Docker Compose File

Use docker to compose your dev environment Working with Apache, PHP, MariaDB, … Here is my sample compose file version: '2.1' services: # PHP 7.0 FPM dev-fpm70: container_name: dev-fpm70 image: oxo/php-fpm:7.0-debian volumes: - /home/michael/workspace:/home/vhosts links: - "dev-db:db" - "dev-mailcatcher:mailcatcher" logging: driver: "json-file" options: max-size: "1g" max-file: "10" environment: LOCAL_USER_ID: 1000 # MailCatcher dev-mailcatcher: container_name: dev-mailcatcher image: oxo/mailcatcher:0.6.5 logging: driver: "json-file" options: max-size: "1g" max-file: "10" # MariaDB dev-db: container_name: dev-db image: oxo/mariadb:10.2-debian user: mysql volumes: - /home/michael/workspace/database:/var/lib/mysql logging: driver: "json-file" options: max-size: "500m" max-file: "9" environment: MARIADB_PASS: password # Apache HTTPd dev-httpd: container_name: dev-httpd image: oxo/httpd:2.4-debian volumes: - /home/michael/workspace:/home/vhosts links: - "dev-fpm70:fpm70" logging: driver: "json-file" options: max-size: "1g" max-file: "10" networks: default: front: ipv4_address: 172.10.0.2 networks: front: driver: bridge ipam: driver: default config: - subnet: 172.10.0.0/16 gateway: 172.10.0.1 How to use it TODO ...

November 23, 2017 · 1 min · 211 words · oxomichael

Convertir un clavier QWERTY (ANSI) en version AZERTY (ISO)

Acheter les autocollants puis les coller. Mais il vous manque les signes supérieur (>) et inférieur (<) Windows Installer AutoHotKey (https://www.autohotkey.com) Lire la documentation (je vous met tous ça là, quand même) Right-Click on your desktop. Find “New” in the menu. Click “AutoHotkey Script” inside the “New” menu. Give the script a new name. Note: It must end with a .ahk extension. Ex. MyScript.ahk Find the newly created file on your desktop and Right-Click it. Click “Edit Script”. A window should have popped up, probably Notepad. If so, SUCCESS! Créer un fichier par exemple keymiss.ahk Saisir le contenu suivant ...

November 19, 2017 · 2 min · 419 words · oxomichael

Deploy PHP Apps with Ansistrano

Deploy PHP Apps with Ansistrano Install Ansible $ sudo apt-get install software-properties-common $ sudo apt-add-repository ppa:ansible/ansible $ sudo apt-get update $ sudo apt-get install ansible In /etc/ansible/ansible.cfg [defaults] host_key_checking = false Install Ansistrano $ ansible-galaxy install carlosbuenosvinos.ansistrano-deploy carlosbuenosvinos.ansistrano-rollback Update If you want to update the role, you need to pass –force parameter when installing. Please, check the following command: $ ansible-galaxy install –force carlosbuenosvinos.ansistrano-deploy carlosbuenosvinos.ansistrano-rollback Ansible repository You could organize your deployment repository by company or by type of project. I call it “ansible” for example, with directory structure : ...

July 16, 2017 · 3 min · 522 words · oxomichael

Create a vagrant box from scratch

Box Debian Stretch 64 Install VirtualBox Install Vagrant Download the Debian net install CD Create the virtual machine Virtual Machine Hardware Name: vagrant-stretch64 Type: Linux Version: vagrant-stretch64 Memory Size: 512MB New Virtual Disk: Type: VMDK Size: 8GB Disable audio Disable USB Mount ISO CD Installation Choose Graphical Install Select a language Select your location Configure locales Configure the keyboard Configure the network Hostname: stretch64 Set up users and passwords Enter “vagrant” as root password Enter “vagrant” as fullname New user as “vagrant” and also “vagrant” as password Configure the clock Partition disks Guided - use entire disk Just let SCSIl (0, 0, 0) (sda) - 8.6 GB ATA VBOX HARDDISK as preselected and continue. All files in one partition Let’s Finish partitioning and write changes to disk. Install the base system Configure the package manager Software select Please disable every option, except standard system utilities. Finish installation Configuration Install sudo $ su ...

June 30, 2017 · 2 min · 322 words · oxomichael