Skip to content

Instantly share code, notes, and snippets.

@neothone
neothone / Dockerfile-apache-php7
Created December 9, 2016 14:53
Fresh Symfony Dockerization for Mac
FROM ubuntu:16.04
MAINTAINER Mathieu DUMOUTIER <mathieu@dumoutier.fr
LABEL version="1.0"
LABEL description="Apache 2 / PHP 7 / phpUnit / Composer"
RUN apt-get -y update && apt-get install -y \
apache2 \
curl \
<?php
/*
+----------------------------------------------------------------------+
| APC |
+----------------------------------------------------------------------+
| Copyright (c) 2006-2011 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
@neothone
neothone / instance-httpclient.php
Last active October 21, 2020 15:57
Instanciation of HttpClient with URL in array
<?php
$httpClient = HttpClient::create();
$request = $httpClient->request(
'GET',
'https://yourapi.com/endpoint',
[
'headers' => ['Accept' => 'application/json', 'Content-Type' => 'application/json']
]
);
# config/packages/framework.yaml
framework:
http_client:
scoped_clients:
your_api:
scope: 'https://yourapi\.com'
headers:
Accept: 'application/json'
Content-Type: 'application/json'
<?php
$httpClient = HttpClient::create();
$request = $httpClient->request(
'GET',
'https://yourapi.com/endpoint'
);
<?php
namespace App\Http;
use Symfony\Component\HttpFoundation\Response;
class TransparentPixelResponse extends Response
{
/**
* Base 64 encoded contents for 1px transparent gif and png
@neothone
neothone / .editorconfig
Last active January 29, 2025 17:38
.editorconfig for Symfony with javascript
# EditorConfig helps developers define and maintain consistent
# coding styles between different editors and IDEs
# editorconfig.org
root = true
[*]
indent_style = space
indent_size = 4
@neothone
neothone / LowerCamelCasePathSegmentNameGenerator.php
Created February 10, 2025 15:33
LowerCamelCasePathSegmentNameGenerator for API Platform 4+
<?php
namespace App\Operation;
use ApiPlatform\Metadata\InflectorInterface;
use ApiPlatform\Metadata\Operation\PathSegmentNameGeneratorInterface;
use ApiPlatform\Metadata\Util\Inflector;
class LowerCamelCasePathSegmentNameGenerator implements PathSegmentNameGeneratorInterface
{
@neothone
neothone / .php-cs-fixer.dist.php
Created February 18, 2025 12:46
PHPCSFixer configuration
<?php
$finder = PhpCsFixer\Finder::create()
->exclude('var')
->exclude('vendor')
->exclude('translations')
->in(__DIR__)
;
return (new PhpCsFixer\Config)
->setRiskyAllowed(true)
->setRules([
@neothone
neothone / gist:bd08f8879ce5dcc5d07869923209a6ea
Created October 1, 2025 12:49
My copilot instructions (PHP with Symfony development)
Use yoda style for conditions.
Use strict modes for PHP type.
Compliant with PHPStan level 6.
Respect the SRP from SOLID principles.
Try to apply SOLID principles.
Use php attributes instead of YAML config in Symfony framework if possible.
With Symfony, don't use #[Template] attribute, use return $this->render() instead.
Use constructor property promotion.
Use typed properties.
Use readonly properties if possible.