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. ????
@javiereguiluz
javiereguiluz / gist:a5514ec6cde2a63be441
Last active May 3, 2017 18:21
How to add a deprecation note about Symfony features

In order to generate and log a warning message about a deprecated Symfony feature, use the trigger_error() function as follows:

trigger_error('The enctype method of the form helper was removed. You should use the new method start instead.', E_USER_DEPRECATED);

Please, be as explicit as possible in the deprecation message and always explain the alternative way to use that feature, property, method or class.

@javiereguiluz
javiereguiluz / gist:a66f084a4f2cf11cf0ee
Last active August 27, 2016 17:47
Discussion about the different solutions to display a flash message

The problem to solve

We want to show a flash message as the result of executing some controller. This message will only last for the next request.

Proposed Solution #1

I propose to use the new addFlash() method available in the base controller of Symfony 2.6:

<?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) {
```css
body {
background-color: #F9F9F9;
color: #222;
font-family: Helvetica, Arial, sans-serif;
font-size: 14px;
line-height: 1.4;
padding: 0;
margin: 0;
}
@javiereguiluz
javiereguiluz / WallpaperNotifier.php
Created April 17, 2012 09:15
The winner proposal of the Sismo Challenge programming contest
<?php
namespace Sismo\Contrib;
use Sismo\Notifier\Notifier;
use Sismo\Commit;
/**
* Notifies builds via the wallpaper (Mac only).
*