Skip to content

Instantly share code, notes, and snippets.

<script>
document.addEventListener('DOMContentLoaded', function() {
const card = document.querySelector('#intro-image-wrapper');
const motionMatchMedia = window.matchMedia('(prefers-reduced-motion)');
const buffer = 10;
function handleHover(e) {
const { clientX, clientY, currentTarget } = e;
const { clientWidth, clientHeight, offsetLeft, offsetTop } = currentTarget;
<?php
class BlogPostCrudController extends AbstractCrudController
{
// ...
// Thanks to this method, admin users can see all blog posts but
// the rest of users can only see their blog posts
public function createIndexQueryBuilder(SearchDto $searchDto, EntityDto $entityDto, FieldCollection $fields, FilterCollection $filters): QueryBuilder
{
<?php
// This code was originally posted in a comment of this blog post:
// https://symfony.com/blog/new-in-symfony-5-2-true-colors-in-the-console
final class Rgb
{
private $red;
private $green;
private $blue;
@javiereguiluz
javiereguiluz / file1.txt
Created February 27, 2019 10:45
Created via API
Demo
Step 1. Download Docker Community edition (https://store.docker.com/search?type=edition&offering=community)
and install it in your computer.
Step 2. Clone the Symfony Demo app in your computer: `git clone git@github.com:symfony/demo.git`
Step 3. ????
Step 4. ????
Step 5. ????
Step 6. ????
Step 7. ????
Step 8. ????
Step 9. ????
```css
body {
background-color: #F9F9F9;
color: #222;
font-family: Helvetica, Arial, sans-serif;
font-size: 14px;
line-height: 1.4;
padding: 0;
margin: 0;
}
<?php
// app/config/routing.php
use Symfony\Component\Routing\RouteCollection;
use Symfony\Component\Routing\Route;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
$collection = new RouteCollection();
$collection->add('closure_controller', new Route('/closure', [
'_controller' => function (Request $request) {
// original code
public function getFunctions()
{
return array(
new \Twig_SimpleFunction('show_source_code', array($this, 'showSourceCode'), array('is_safe' => array('html'), 'needs_environment' => true)),
);
}
// new code
@javiereguiluz
javiereguiluz / gist:ec86ff09c05eabac492d
Last active August 29, 2015 14:17
Symfony en 1 minuto

Linux y Mac OS X

# (30 segundos) Instalar el Instalador de Symfony
$ sudo curl -LsS http://symfony.com/installer -o /usr/local/bin/symfony
$ sudo chmod a+x /usr/local/bin/symfony

# (10 segundos) Crear un nuevo proyecto Symfony
$ symfony new nombre_proyecto
@javiereguiluz
javiereguiluz / har2blackfire.php
Last active August 29, 2015 14:14
Transforms HAR file format to Blackfire file format
<?php
// Transforms a HAR (HTTP Archive) file into a BK file to analyze it using
// Blackfire Profiler (https://blackfire.io/)
//
// USAGE:
// $ php har2blackfire.php name-of-the-HAR-file.har
$harFile = $argv[1];
$harData = json_decode(file_get_contents($harFile), true);