Outils pour utilisateurs

Outils du site


blog

Notes PHP symphony

Point à vérifier si MEP (Mise En Production)

symfony1 :

#composer require lexpress/symfony1 "1.5.*"
composer create-project lexpress/symfony1 sf1
composer create-project symfony/framework-standard-edition sf2

Notes composer

#mkdir $HOME/htdocs/bin/
#export COMPOSER_HOME=$HOME/htdocs/bin/
 
cd /usr/local/bin/
 
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
php -r "if (hash_file('sha384', 'composer-setup.php') === '48e3236262b34d30969dca3c37281b3b4bbe3221bda826ac6a9a62d6444cdb0dcd0615698a5cbe587c3f0fe57a54d8f5') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
php composer-setup.php
php -r "unlink('composer-setup.php');"
 
mv composer.phar composer

Voir https://getcomposer.org/download/

Exemple :

composer.json

{
    "require": {
        "monolog/monolog": "1.0.*"
    }
}

Vider le cache

Une façon comme une autre

rm -rf /var/www/MonApp/cache/*

Pb PHP Symphony cache app.php

https://openclassrooms.com/forum/sujet/symfony2-app-php-ne-marche-pas-76345

Vider le cache sur Symphony 2

cd /var/www/MonApp
php app/console cache:clear --env=prod
chown -R apache: ./app/cache

Vider le cache sur Symphony 1

su - apache
cd /var/www/MonApp
php symfony cc
exit
Autre

(Symfony 1)

symfony plugin:publish-assets
2025/03/24 15:06

Notes PHP Capifony

Liens :

Si besoin renseigner le fichier auth.json

~/.composer/auth.json

{
    "github-oauth": {
        "github.com": "fffffffffffffffff"
    }
}
chmod 600 ~/.composer/auth.json

ou

composer config -g --unset github-oauth.api.github.com
composer config -g github-oauth.github.com __TOKEN__

app/config/deploy.rb

set :stages, %w(preprod prod)
set :default_stage, "preprod"
set :stage_dir, "app/config"
require 'capistrano/ext/multistage'
# Be more verbose by uncommenting the following line
logger.level = Logger::MAX_LEVEL

app/config/prod.rb

set :application, "Test1"
#set :domain,      "test.local"
set :domain,      "plop"
set :deploy_to,   "/var/www/#{domain}"
set :app_path,    "app"
ssh_options[:port] = "22"
#set :deploy_via, :rsync_with_remote_cache
set   :deploy_via,       :capifony_copy_local
 
#set :repository,  "#{domain}:/var/repos/#{application}.git"
set :repository,  "https://nom:P@ssw0rd@github.com/acme/projet"
set :scm,         :git
# Or: `accurev`, `bzr`, `cvs`, `darcs`, `subversion`, `mercurial`, `perforce`, or `none`
 
set :model_manager, "doctrine"
# Or: `propel`
 
role :web,        domain                         # Your HTTP server, Apache/etc
role :app,        domain, :primary => true       # This may be the same as your `Web` server
 
set  :keep_releases,  3
 
# Be more verbose by uncommenting the following line
#logger.level = Logger::MAX_LEVEL
 
# http://capifony.org/reference/symfony.html
# http://www.disko.fr/reflexions/technique/deploiement-capifony/
set :shared_files, ["app/config/parameters.yml"] # Les fichiers à conserver entre chaque déploiement
set :shared_children, [app_path + "/logs", "vendor"] # Idem, mais pour les dossiers
set :use_composer, true
set :use_composer_tmp, true
set :update_vendors, false
#set :update_vendors, true
set :writable_dirs, ["app/cache", "app/logs"] # Application des droits nécessaires en écriture sur les dossiers
 
set :webserver_user, "apache" # L’utilisateur de votre serveur web (Apache, nginx, etc.)
# Pas d'ACL donc chown
set :permission_method, :chown
 
#set :interactive_mode, false
after "deploy", "deploy:cleanup"
 
 
set   :use_sudo,      false
#default_run_options[:pty] = true
 
ssh_options[:forward_agent] = true
#set :composer_options, "--no-dev --verbose --prefer-dist --optimize-autoloader --no-progress"
 
#before "deploy:share_childs",  "upload_parameters"
after  "symfony:cache:warmup", "symfony:doctrine:migrations:migrate"
set :assets_install,      true
set :dump_assetic_assets, true

FIXME

2025/03/24 15:06

Notes permissions Unix POSIX

Voir :

$ stat -c "%a %A" ~/test/
1770 drwxrwx--T
$ stat -c "%a %U:%G %n" /usr/bin/passwd
4701 root:root /usr/bin/passwd

FIXME

2025/03/24 15:06

Notes Perl

Variables PATH

PERL5LIB

$ env -i perl -V
...
@INC:
 /usr/lib/perl5/site_perl/5.18.0/x86_64-linux-thread-multi-ld
 /usr/lib/perl5/site_perl/5.18.0
 /usr/lib/perl5/5.18.0/x86_64-linux-thread-multi-ld
 /usr/lib/perl5/5.18.0
 .
PATH="/home/jean/perl5/bin${PATH:+:${PATH}}"; export PATH;
PERL5LIB="/home/jean/perl5/lib/perl5${PERL5LIB:+:${PERL5LIB}}"; export PERL5LIB;
PERL_LOCAL_LIB_ROOT="/home/jean/perl5${PERL_LOCAL_LIB_ROOT:+:${PERL_LOCAL_LIB_ROOT}}"; export PERL_LOCAL_LIB_ROOT;
PERL_MB_OPT="--install_base \"/home/jean/perl5\""; export PERL_MB_OPT;
PERL_MM_OPT="INSTALL_BASE=/home/jean/perl5"; export PERL_MM_OPT;

CPAN

Installer un module

cpan JSON

Installer un module téléchargé localement

tar xzvf JSON-4.10.tar.gz
cd JSON-4.10/
perl Makefile.PL PREFIX=~
make test
make install

code-style-guidelines (exemple)

Source : https://github.com/centreon/centreon-plugins/blob/develop/doc/en/developer/plugins_global.md#5-code-style-guidelines

Code Style Guidelines Introduction

Perl code from Pull-request must conform to the following style guidelines. If you find any code which doesn't conform, please fix it.

1 Indentation

Space should be used to indent all code blocks. Tabs should never be used to indent code blocks. Mixing tabs and spaces results in misaligned code blocks for other developers who prefer different indentation settings. Please use 4 for indentation space width.

    if ($1 > 1) {
    ....return 1;
    } else {
        if ($i == -1) {
        ....return 0;
        }
        return -1
    }
2 Comments

There should always be at least 1 space between the # character and the beginning of the comment. This makes it a little easier to read multi-line comments:

    # Good comment
    #Wrong comment
3 Subroutine & Variable Names

Whenever possible, use underscore to seperate words and don't use uppercase characters:

    sub get_logs {}
    my $start_time;

Keys of hash table should use alphanumeric and underscore characters only (and no quote!):

    $dogs->{meapolitan_mastiff} = 10;
4 Curly Brackets, Parenthesis

There should be a space between every control/loop keyword and the opening parenthesis:

    if ($i == 1) {
        ...
    }
    while ($i == 2) {
        ...
    }
5 If/Else Statements

'else', 'elsif' should be on the same line after the previous closing curly brace:

    if ($i == 1) {
        ...
    } else {
        ...
    }

You can use single line if conditional:

    next if ($i == 1);
Suite

libraries Strict and warnings are mandatory

use strict;
use warnings;

Autres

use feature bitwise;

https://perldoc.pl/feature

2025/03/24 15:06
blog.txt · Dernière modification : de 127.0.0.1

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki