Skip to content

Commandes utiles (Symfony, SQL)

Raphaël Odini edited this page Sep 19, 2024 · 2 revisions

Auteur: Sylvain Martin

Date: 31-jul-2022

Clear the cache

php bin/console cache:clear

Anonymize the database

A script helps to anonymizing the database by replacing the first and last name, the email, the physical address (street, zip code and city) and the phone number of each beneficiary. But it does not change the message text exchanged with the beneficiaries. The script also updates the Commission table (name and description)

php bin/console app:anonymize

Dumping the assets

The application use assetic to manage static assets (like js, and css files). to 'dump' them (meaning to install them at the right place). one should execute the following command:

# --env=prod --no-debug for prod
php bin/console assetic:dump --env=prod --no-debug

to install new assets from the bundles web assets (under a public directory ``src/AppBundle/Resources/public

php bin/console assets:install                           

User management

Introduction

The users are managed by FOSUserBundle. The documentation can be found here. the most useful Symfony console commands in dev mod are:

# Activate a user manually (without needing a confirmation email) 
php bin/console fos:user:activate $username

# change a user's password
php bin/console fos:user:change-password $username newp@ssword

List of commands

command Description
fos:oauth-server:clean Clean expired tokens
fos:oauth-server:create-client Creates a new client
fos:user:activate Activate a user
fos:user:change-password Change the password of a user
fos:user:create Create a user
fos:user:deactivate Deactivate a user
fos:user:demote Demote a user by removing a role
fos:user:promote Promotes a user by adding a role

Créer un utilisateur non-membre

Exemple ci-dessous pour un compte non-membre admin. Mot de passe à réinitialiser lors de la première connexion.

INSERT INTO fos_user (username, username_canonical, email, email_canonical, enabled, password, roles) VALUES ('prenom', 'prenom', '[email protected]', '[email protected]', 1, 'password', 'a:1:{i:0;s:10:"ROLE_ADMIN";}');

Ajouter un rôle

// à une formation
SELECT * from formation;
UPDATE formation SET roles = 'a:2:{i:0;s:17:"ROLE_USER_MANAGER";i:1;s:20:"ROLE_PROCESS_MANAGER";}' WHERE id = 30;

Server logs

To follow logs in real time, execute the following command:

bin/console server:log -vv`

Misc

sudo su -l www-data -s /bin/bash