Show Menu
Cheatography

Composer,PSR standards Cheat Sheet (DRAFT) by

composer for install packages

This is a draft cheat sheet. It is a work in progress and is not finished yet.

Composer

Win install: https:­//g­etc­omp­ose­r.o­rg/­dow­nload/
Packages: https:­//p­ack­agi­st.org/
howto (czech): https:­//w­ww.i­tn­etw­ork.cz­/ph­p/o­op/­com­poser/
composer --version //check version and if exists

composer init //generate compos­er.json file

composer install //download packages from compos­er.json

composer require phpmai­ler­/ph­pmailer //download phpmailer

composer update //update all packages

composer update phpmai­ler­/ph­pmailer //update phpmailer

Inicia­lizace
index.php
require __DIR__ . '/vend­or/­aut­olo­ad.p­hp';

$mail=new PHPMai­ler­\PH­PMa­ile­r\P­HPM­ailer;

Symfony

Symfony install:
composer create-project symfony/website-skeleton:"^5" hello-world
composer create-project symfony/skeleton:"6.1.*" my_project_directory

run server: 
php -S 127.0.0.1:8000 -t public

Apache setting:
//.htaccess
<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteRule ^$ public [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_URI} !^public/
    RewriteRule ^(.*)$ public/$1
</IfModule>

install:
composer require symfony/apache-pack

show list of make function
php bin/console list make

Generator controller
php bin/console make:controller
 

PSR-st­andards

PSR-0: Autolo­adi­ng(old)
PSR-1: coding standard basic
PSR-2: coding standard extend
PSR-3: logger interface
PSR-4: Autolo­adi­ng(new)
PSR-5: PHPDoc
PSR-6: Caching Interface
PSR-7: interfaces for HTTP message interfaces
PSR-11: Dependenci Injections
PSR-13: Link
PSR-14: Event Dispatcher
PSR-15: Request Handlers
PSR-16: Common Interface for Caching Libraries
PSR-17: Factories
PSR-18: HTTP client

Docker

https://hub.docker.com/ //images

docker version //show if exist
docker build -t api_python .//built image container
docker run -d --name apicontainer -p 8080:8080 api_python:latest
docker -p //show all running containers
docker run apicontainer 
docker kill apicontainer
docker start apicontainer
docker pause apicontainer
docker unpause apicontainer
docker ps --all //show all containers
docker ps --filter status=paused

docker exec -it apicontainer sh // edit running container
docker restart apicontainer
docker rm apicontainer
docker image rm api_python

linux

pwd //show actual path