Skip to content

Instantly share code, notes, and snippets.

View atillay's full-sized avatar

Alexandre Tillay atillay

View GitHub Profile
<?php
namespace App\Entity;
use ApiPlatform\Core\Annotation\ApiResource;
/**
* @ApiResource(
* collectionOperations={
* "post"
<?php
namespace App\Entity;
use ApiPlatform\Core\Annotation\ApiResource;
use Symfony\Component\Validator\Constraints as Assert;
/**
* @ApiResource(
* collectionOperations={
<?php
declare(strict_types=1);
namespace App\Validator;
use Symfony\Component\HttpFoundation\RequestStack;
final class ValidationGroupsGenerator
{
<?php
namespace App\Entity;
use ApiPlatform\Core\Annotation\ApiResource;
/**
* @ApiResource(
* collectionOperations={
* "get",
<?php
namespace App\Serializer;
use ApiPlatform\Core\Serializer\SerializerContextBuilderInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface;
final class GroupsContextBuilder implements SerializerContextBuilderInterface
{
<?php
namespace App\Entity;
use ApiPlatform\Core\Annotation\ApiResource;
/**
* @ApiResource(
* collectionOperations={
* "get"={
@atillay
atillay / gitlab-ci.yml
Last active October 29, 2024 14:58
Deploy to Gandi Simple Hosting with Gitlab CI (and build assets with NPM)
image: node:lts-slim
before_script:
- 'which ssh-agent || ( apt-get update -y && apt-get install openssh-client git -y )'
- mkdir -p ~/.ssh
- eval $(ssh-agent -s)
- '[[ -f /.dockerenv ]] && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config'
- ssh-add <(echo "$SSH_PRIVATE_KEY")
stage_deploy:
@atillay
atillay / doc.md
Last active August 22, 2018 07:37
Setup PHPCS, PHPMD and PHP-CS-FIXER with Intellij globally

Run the following commands :

  • $ composer global require phpmd/phpmd
  • $ composer global require squizlabs/php_codesniffer
  • $ composer global require friendsofphp/php-cs-fixer
  • $ nano ~/.bash_profile and put export PATH=~/.composer/vendor/bin:$PATH (make sure path is correct)
  • $ source ~/.bash_profile

Go to Intellij > Preferences > Languages & Frameworks > PHP and add path for Mess Detector and Code Sniffer (ex: ~/.composer/vendor/bin/phpmd)
Go to Intellij > Preferences > Editor > Inspections and enable PHP Mess Detection validation + PHP Code Sniffer validation

@atillay
atillay / yolo.php
Last active May 27, 2018 19:39
yolo
<?php
define('PATTERN', '*.{jpg,jpeg,gif,png}');
function getFilesIn(string $path): array
{
$files = glob($path . '/' . PATTERN, GLOB_BRACE);
foreach (glob($path . '/*', GLOB_ONLYDIR|GLOB_NOSORT) as $subDir) {
$files = array_merge($files, getFilesIn($subDir));
@atillay
atillay / DemoController.php
Last active July 24, 2024 17:19
Symfony 4 Pagination Service
<?php
namespace App\Controller;
use App\Entity\Demo;
use App\Service\PaginationService;
use Symfony\Component\HttpFoundation\Request;
class DemoController extends AdminController
{