Posts

Showing posts with the label PHP

Composer life hacks

Image
Composer life hacks Switching between composer 1 & 2: composer  self-update --1   --> switch to composer 1 composer  self-update --2   -->  switch to composer 2 If you only want to install, upgrade or remove one dependency, you can explicitly list it as an argument: php composer.phar update monolog/monolog [...] composer dump-env dev - will generate .env.local.php (which you can change with your needs) Installing tools globally: php composer.phar global require friendsofphp/php-cs-fixer or just  composer global require friendsofphp/php-cs-fixer

Interesting PHP composer packages

Image
Interesting PHP composer packages for your projects   ( to be continued ... ) jokkedk/webgrind  -  Webgrind is an  Xdebug  profiling web frontend in PHP woohoolabs/yang - Woohoo Labs. Yang is a PHP framework that helps you to communicate with JSON:API servers more easily. vimeo/psalm  - A static analysis tool for finding errors in PHP applications rectorphp/rector - Rector is an open-source tool that helps with automatic PHP upgrades and code refactorings in bulk. PhpStorm 2022.2 allows you to easily run Rector on your code base and selectively apply fixes in bulk. graham-campbell/result-type   -  An implementation of the result type netresearch/jsonmapper - Map nested JSON structures onto PHP classes lesstif/php-jira-rest-client - for creating tickets in Jira and using its API vlucas/phpdotenv - Loads environment variables from `.env` to `getenv()`, `$_ENV` and `$_SERVER` automatically. webmozart/assert  -  This library contains efficient assertions to test the input and output

Выборка первого и последнего дней месяца по дате (selecting the first, last days given date) (php)

Image
Выборка 1-го дня и последнего дня месяца по дате (php)  <?php  $query_date = '2010-02-04';   // First day of the month.  echo date('Y-m-01', strtotime($query_date));   // Last day of the month.  echo date('Y-m-t', strtotime($query_date)); или $first = date("Y-m-d", strtotime("first day of this month"));  $last = date("Y-m-d", strtotime("last day of this month")); или $date = new \DateTime('2021-02-05'); $first = $date->format("Y-m-01");  $last = $date->format("Y-m-t");    пример: https://3v4l.org/X6rO9 часть инфы взята отсюда  https://stackoverflow.com/questions/7541938/how-to-get-the-first-and-last-days-of-a-given-month

Быстрая настройка phpUnit для phpStorm и решение проблемы с падением тестов с --teamcity флагом

Image
Быстрая настройка phpUnit для phpStorm и решение проблемы с падением тестов с --teamcity флагом Устанавливаем  composer require --dev symfony/phpunit-bridge В консоли в папке проекта запускаем ./bin/phpunit В настройках phpStorm (версия 2019.1) переходим в настройки Test Framewors  и ставим checkbox на path to phar file , а не на composer autoload и прописываем(выбираем):  папка_проекта /bin/phpunit  не файл с расширением .phar a именно /bin/phpunit (бинарник), т.к. у Вас там может быть и /bin/phpunit.phar , но он нам не подходит. Ставим галку на Default configurations file выбираем этот  файл phpunit.xml.dist в корне вашего проекта. Если вдруг у вас вываливается ошибка на --teamcity,  то Вам нужно удалить phpUnit из системы командой sudo apt remove phpunit-* и повторить 2 и 3 шаги. мне помогло избавиться от проблемы с --teamcity и перейти с версии phpUnit 6.5 на 8.3 для php7.2, надеюсь данный рецепт Вам тоже поможет. Хорошего Вам тесто-кодо-писания! )

Executing php scripts in background + monitoring it in Linux (links)

Executing php scripts in background + monitoring it in Linux How to execute a shell command using PHP without await for the result (asynchronous) in Linux and windows environments php execute a background process + monitoring it in Linux

Sonata Admin Bundle start guide (repost)

http://slides.com/akovalyov/sonata-admin-start-guide

Vagrant + Windows (some useful links)

Vagrant + Windows (some useful links) Getting Started with Vagrant on Windows Change VAGRANT_HOME directory on windows   Vagrant and Windows и на закуску: 5 Easy Ways to Get Started with PHP on Vagrant   Vagrant для PHP-проекта  

Очереди на PHP

Вот отличное слайд-шоу на эту тему: http://www.slideshare.net/fwdays/php-54057177 и немного ссылок: https://github.com/chrisboulton/php-resque PHP Rescue with phpredis | kamisama.me PHP и Gearman — Toster.ru Выбор системы организации очередей для PHP :: Web-программирование :: Компьютерный форум Ru.Board

Раскрашиваем консоль Windows + php

http://stackoverflow.com/questions/7086034/colorizing-windows-command-line-output-from-php?answertab=active#tab-top http://softkube.com/blog/ansi-command-line-colors-under-windows http://softkube.com/blog/generating-command-line-colors-with-php https://github.com/adoxa/ansicon

Как врапперы PHP могут быть использованы для атаки на веб-приложения

Как врапперы PHP могут быть использованы для атаки на веб-приложения Использование враппера php://filter в контексте атаки на веб-приложения Уязвимости альтернативных реализаций PHP 

PHP - тест

Image
:-)

Хранение PHP-сессий в базе данных « MySQL « Ars Longa, Vita Brevis

Хранение PHP-сессий в базе данных « MySQL « Ars Longa, Vita Brevis

Ответы на вопросы в интервью по веб разработке

В PHP 5.3 появился ActiveRecord аналогичный Ruby on Rails

В PHP 5.3 появился ActiveRecord аналогичный Ruby on Rails

jsmin-php - Google Code

jsmin-php - Google Code : "This is a fast, low-overhead port of Douglas Crockford's JSMin JavaScript minifier to PHP. It requires PHP 5 or higher. Usage require 'jsmin-1.1.1.php'; // Output a minified version of example.js. echo JSMin::minify(file_get_contents('example.js'));"