Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Some Handy Laravel Packages

Freek Van der Herten
November 17, 2016
260

Some Handy Laravel Packages

Given at the Laravel meetup at #phpantwerp

Freek Van der Herten

November 17, 2016
Tweet

Transcript

  1. About me Freek Van der Herten Partner & developer at

    SPATIE @freekmurze https://murze.be
  2. Since 2003 Websites, applications and webshops Team 4 developers, 1

    manager Specialization Laravel development
  3. Open source software We use a lot of it Nginx,

    Laravel, Ubuntu, Elasticsearch, Memcached, Redis, Beanstalkd, MySQL, Composer, Glide, Homestead, Flysystem, Fractal, Carbon, PHPUnit, NPM, React, jQuery, Java, SSH, Sequel Pro, BackupPC … Basically everything listed in composer.json and package.json
  4. ± 90 packages on Packagist Laravel, Framework agnostic PHP +

    1 200 000 downloads in total, growing 200 000 a month We create a lot of it Open source software
  5. 2. pdf-to-image $pdf = new Spatie\PdfToImage\Pdf('file.pdf');
 $pdf->saveImage($pathToImage);
 
 collect(range(1, $pdf->getNumberOfPages()),

    function(int $pageNumber) use ($pdf) {
 $pdf->setPage($pageNumber)
 ->saveImage("page{$pageNumber}.jpg");
 });
  6. Laravel Menu Menu::macro('main', function () {
 return Menu::new()
 ->action('HomeController@index', 'Home')


    ->action('AboutController@index', 'About')
 ->action('ContactController@index', 'Contact')
 ->setActiveFromRequest();
 });
  7. Speed up your application 
 by caching the entire response

    Laravel Responsecache RESPONSE CACHE REQUESTS APP 1 2
  8. Laravel Translatable $newsItem = new NewsItem; // This is an

    Eloquent model
 $newsItem
 ->setTranslation('name', 'en', 'Name in English')
 ->setTranslation('name', 'nl', 'Naam in het Nederlands')
 ->save();
 
 $newsItem->name; // Returns 'Name in English'
 $newsItem->getTranslation('name', 'nl');
  9. Laravel Tags $newsItem = NewsItem::create([
 'name' => 'testModel',
 'tags' =>

    ['tag', 'tag2'],
 ]);
 
 $newsItem->attachTags(['tag4', 'tag5']);
 $newsItem->detachTags(['tag4', 'tag5']);
 $newsItem->syncTags(['tag1', 'tag2']);
 
 NewsItem::withAnyTags(['tag1', 'tag2']);
 NewsItem::withAllTags(['tag1', ‘tag2']);