Skip to content

Instantly share code, notes, and snippets.

@caillioux
caillioux / run.php
Last active August 25, 2020 14:13
<?php
include 'vendor/autoload.php';
use Aws\S3\S3Client;
use League\Flysystem\AwsS3v3\AwsS3Adapter;
use League\Flysystem\Filesystem;
$client = new S3Client([
'credentials' => [
'key' => '*************',
'secret' => '****************',

A grep command to search for a popular string in a vendor/ directory.

It aims to be more efficient (performance, readability) than what IDE commonly do :

grep -rlP 'sylius\.grid' vendor/ | grep -vP 'xml|Test|rst'

  1. Find all occurences in vendors -r vendor/ with a regex -P for 'syliusDOTgrid', 'DOT' being a real dot between 'sylius' and 'grid', but only display file names -l to avoid dozens of matches being in those files
  2. Pipe | results and exclude grep -v with a regex -P files containing 'xml', 'Test' or 'rst' xml|Test|rst in their path, since these files usually have lots of occurences and not the golden piece of code you search for ;)

It remains simple to write and efficient, do you have other tips with grep?

#!/bin/sh
cwd=`pwd`
if [ ! -f $cwd/vendor/bin/phpunit ]; then
echo "No local phpunit found."
exit 1
fi
php vendor/bin/phpunit