Skip to content

Instantly share code, notes, and snippets.

@GrzegorzBandur
GrzegorzBandur / Readme.md
Last active May 2, 2021
RESTful API with Symfony 4.4 + FOSRestBundle + FOSOauthServerBundle + FOSUserBundle
View Readme.md

RESTful API with Symfony 4.4 + FOSRestBundle + FOSOauthServerBundle + FOSUserBundle

To start writing RestFull API in symfony we will need bundles:

        "friendsofsymfony/oauth-server-bundle": "^1.6",
        "friendsofsymfony/rest-bundle": "^2.7",
        "friendsofsymfony/user-bundle": "^2.1",
        "jms/serializer-bundle": "^3.5",
        "nelmio/api-doc-bundle": "^3.5",
        "sensio/framework-extra-bundle": "^5.2",
        "symfony/apache-pack": "^1.0",
@adamsafr
adamsafr / AbstractBySlugAndActiveSearcher.php
Last active Feb 19, 2021
Symfony: ParamConverter usage example
View AbstractBySlugAndActiveSearcher.php
<?php
namespace FrontEndBundle\Request\ParamConverter;
use Doctrine\Bundle\DoctrineBundle\Registry;
use Doctrine\Common\Persistence\ObjectRepository;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
abstract class AbstractBySlugAndActiveSearcher
@cereal-s
cereal-s / ping.gs.php
Created Sep 8, 2017
Get number of pages from a PDF, using GhostScript.
View ping.gs.php
<?php
/**
* Return the number of pages of a PDF.
*
* Imagick::pingImage() takes too much when dealing with big files.
*
* Command to execute:
*
* gs -q -dNODISPLAY -c "(%s) (r) file runpdfbegin pdfpagecount = quit"
@nclavaud
nclavaud / MangoPayApiPhpUnitMock.php
Created Apr 20, 2017
MangoPay API PHPUnit mock
View MangoPayApiPhpUnitMock.php
<?php
namespace Lrqdo\Tests;
use MangoPay\ApiWallets;
use MangoPay\MangoPayApi;
use MangoPay\Money;
use MangoPay\Wallet;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
@treetop1500
treetop1500 / FlatpickerDateTimeType.php
Last active Feb 2, 2021
Symfony3 Form Extension for use with Flatpickr javascript date/time pickers
View FlatpickerDateTimeType.php
<?php
namespace MyBundle\Form\Extension;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Form\Extension\Core\Type\DateTimeType;
/**
* Class FlatpickrDateTimeType
* @package MyBundle\Form\Extension
@Seldaek
Seldaek / bench.php
Created Dec 8, 2015
strtr vs str_replace benchmark
View bench.php
<?php
$jobs = array(
'old/strtr' => function($args) {
$classes = [];
foreach ($args as $class) {
$classes[] = strtr($class, '\\', DIRECTORY_SEPARATOR);
}
return $classes;
},
@lumpysimon
lumpysimon / wp-disable-rest.php
Created Nov 26, 2015
Completely disable WordPress REST API
View wp-disable-rest.php
add_filter( 'rest_enabled', '_return_false' );
add_filter( 'rest_jsonp_enabled', '_return_false' );
@maxgalbu
maxgalbu / Switch_Node.php
Last active Dec 31, 2019
Switch tag for Twig, updated from https://github.com/fabpot/Twig/pull/185 to work with Twig >= 1.12
View Switch_Node.php
<?php
//To be added under Twig/Node/Switch.php
/*
* This file is part of Twig.
*
* (c) 2009 Fabien Potencier
* (c) 2009 Armin Ronacher
*
@suzuki
suzuki / mail2.php
Created Feb 2, 2014
Swift Mailer sample / DKIM email
View mail2.php
<?php
require 'vendor/autoload.php';
$transport = Swift_SmtpTransport::newInstance('localhost', 25);
$mailer = Swift_Mailer::newInstance($transport);
// DKIM 用の Signer を作成する
$privateKey = file_get_contents('./default.private');
$domainName = 'example.com';
@leylaso
leylaso / pad.js
Created Mar 28, 2012
custom pad.js file for etherpad-lite allows setting author names as line numbers
View pad.js
/**
* @file
* This file is an example of ways to modify etherpad-lite behaviour from the
* static/custom/pad.js file generated by etherpad-lite on first run.
*/
var edBod = [];
var lastLine = 0;
/**