Skip to content

Instantly share code, notes, and snippets.

View yapro's full-sized avatar
:octocat:
a simple man ٩(◕‿◕)۶

Николай Лебеденко yapro

:octocat:
a simple man ٩(◕‿◕)۶
View GitHub Profile
<?php
declare(strict_types=1);
namespace HappyInc\Infrastructure\Migrations;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
@Raistlfiren
Raistlfiren / Dockerfile
Last active August 14, 2023 19:02
XDebug 3 and Docker Reference
FROM php:7.4-cli-alpine
# Install xdebug
RUN apk add --no-cache --virtual .phpize-deps $PHPIZE_DEPS \
&& pecl install xdebug \
&& docker-php-ext-enable xdebug \
&& apk del .phpize-deps
WORKDIR /var/www/html
@prog
prog / .gitlab-ci.yml
Created December 14, 2017 07:30
How to use composer (php) including cache with gitlab-ci
build:install-vendor:
stage: build
image: <any-image-with-composer>
before_script:
- composer config -g cache-dir "$(pwd)/.composer-cache"
script:
- composer install --ignore-platform-reqs --no-dev --optimize-autoloader --no-ansi --no-interaction --no-progress
cache:
paths:
- .composer-cache/
@kamermans
kamermans / php-error-logstash.conf
Last active July 31, 2023 11:31
Logstash parser for PHP's error_log to combine multline stack traces / errors into one event
input {
stdin {
codec => multiline {
pattern => "^\[%{MONTHDAY}-%{MONTH}-%{YEAR} %{TIME} %{TZ}\]"
negate => true
what => "previous"
auto_flush_interval => 10
}
type => "php-error"
}
@odan
odan / php-pdo-mysql-crud.md
Last active December 8, 2020 23:24
Basic CRUD operations with PDO and MySQL
@CarsonF
CarsonF / composer.sh
Last active January 19, 2024 11:10
Global Composer Setup
#!/usr/bin/env bash
# As root
# Make config and data dirs
mkdir /etc/composer -p || exit 1
mkdir /var/lib/composer -p
# Set composer home dir to global location
cat << EOF > /etc/profile.d/composer.sh
#!/usr/bin/env bash
<?php
class Item
{
private $cost = 100;
public function getTotal($discount = 7) {
return $this->cost *(100+$discount)/100;
}
}
@rahul286
rahul286 / nginx-plus-install.sh
Created June 11, 2015 06:25
nginx-plus installation
mkdir /etc/ssl/nginx
wget -P /etc/ssl/nginx/ https://cs.nginx.com/static/files/CA.crt
## move nginx-repo.crt to /etc/ssl/nginx/nginx-repo.crt
## move nginx-repo.key to /etc/ssl/nginx/nginx-repo.key
wget http://nginx.org/keys/nginx_signing.key
apt-key add nginx_signing.key
apt-get install apt-transport-https libgnutls26 libcurl3-gnutls
printf "deb https://plus-pkgs.nginx.com/ubuntu `lsb_release -cs` nginx-plus\n" >/etc/apt/sources.list.d/nginx-plus.list
@johnkary
johnkary / app_dev.php
Created January 4, 2015 21:51
Allow setting breakpoints in Symfony component code when step debugging with Xdebug. Disables cached/compiled files when step debugging. Thanks Joshua Thijssen <https://www.adayinthelifeof.nl/2014/12/31/debugging-symfony-components/> and Antonio J. García Lagar <http://aj.garcialagar.es/blog/debugging-symfony-with-xdebug-2/> for the inspiration.
<?php
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Debug\Debug;
// If you don't want to setup permissions the proper way, just uncomment the following PHP line
// read http://symfony.com/doc/current/book/installation.html#configuration-and-setup for more information
//umask(0000);
// This check prevents access to debug front controllers that are deployed by accident to production servers.
@kelvinn
kelvinn / cmd.sh
Created July 24, 2014 02:55
Example of using Apache Bench (ab) to POST JSON to an API
# post_loc.txt contains the json you want to post
# -p means to POST it
# -H adds an Auth header (could be Basic or Token)
# -T sets the Content-Type
# -c is concurrent clients
# -n is the number of requests to run in the test
ab -p post_loc.txt -T application/json -H 'Authorization: Token abcd1234' -c 10 -n 2000 http://example.com/api/v1/locations/