Skip to content

Instantly share code, notes, and snippets.

View lwillems's full-sized avatar

Laurent WILLEMS lwillems

View GitHub Profile
@lwillems
lwillems / CsvService.php
Last active November 17, 2022 08:03
Easyadmin csv export using leagueCsv and iterable (inspired from https://symfonycasts.com/screencast/easyadminbundle/global-action)
<?php
public function exportAdminData(QueryBuilder $queryBuilder, FieldCollection $fields, string $entityName): StreamedResponse
{
$headers = [];
$properties = array_keys($queryBuilder->getQuery()->setMaxResults(1)->getSingleResult(AbstractQuery::HYDRATE_ARRAY));
foreach ($properties as $property) {
$headers[$property] = ucfirst($property);
foreach ($fields as $field) {
// Override property name if a custom label was set
if ($property === $field->getProperty() && $field->getLabel()) {
<?php
namespace App\Controller;
use App\Service\CsvExporter;
use EasyCorp\Bundle\EasyAdminBundle\Controller\AdminController as BaseAdminController;
class AdminController extends BaseAdminController
{
/**
@lwillems
lwillems / repo-reset.md
Created May 27, 2018 08:28 — forked from heiswayi/repo-reset.md
GitHub - Delete commits history with git commands

First Method

Deleting the .git folder may cause problems in our git repository. If we want to delete all of our commits history, but keep the code in its current state, try this:

# Check out to a temporary branch:
git checkout --orphan TEMP_BRANCH

# Add all the files:
git add -A
@lwillems
lwillems / build_pcntl.sh
Created December 13, 2017 09:36 — forked from jbanety/build_pcntl.sh
Build PCNTL ext for MAMP PHP 7.1.1
# Command lines tools
xcode-select --install
# Install dependencies
brew install wget autoconf openssl libjpeg libpng lzlib curl imap-uw readline postgresql libxml2 mcrypt gettext libxslt homebrew/dupes/libiconv icu4c expat bison webp freetype
# Dirs
mkdir -p /Applications/MAMP/bin/php/php7.1.1/include
cd /Applications/MAMP/bin/php/php7.1.1/include