Générer un mot de passe sécurisé en PHP (Version 2025)
La génération de mots de passe robustes est un élément fondamental de la sécurité des applications. Un mot de passe fort doit être long et contenir une combinaison de différents types de caractères. Une approche dépassée, souvent vue dans d’anciens tutoriels, utilisait des fonctions comme rand() et srand(). Celles-ci ne sont pas considérées comme suffisamment sécurisées pour des tâches cryptographiques. Voici une solution moderne et sûre pour générer des mots de passe en PHP. ...
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. ...
Configure Nextcloud with a reverse proxy (nginx)
How to configure Nextcloud with a reverse proxy and add secure header correctly. NextCloud with Apache Our nextcloud instance will be install with Apache/PHP-FPM In your vhost config or in .htaccess comment some line as below <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 ...
Symfony Flex
(In progress….) Symfony 3.4 (and 4.0) Read the manual https://symfony.com/doc/current/best_practices/creating-the-project.html Install version 3.4 LTS composer create-project symfony/skeleton:3.4 sf34 Get your needed pack composer require symfony/profiler-pack symfony/debug-pack
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 ...
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. ...
Using inotify
Description With inotify you could add a watch descriptor on a file, and send notifications to the system when an event affect the file. As a reminder, in the UNIX world, a file can represent a simple file as well as a directory, a device, a link, etc. The main events that can be followed are : IN_ACCESS : the file is read ; IN_MODIFY : the file is modified ; IN_ATTRIB : the file attributs are modified ; IN_OPEN : the file is open ; 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 watch directory ; IN_CREATE : a file has been created in the watch directory ; Incron $ apt-get install incron When install is completed, you need to insert users, which authorize to use incron, in the file /etc/incron.allow ...
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 ...
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 ...
Ansistrano Deployement
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 : ...