PLATFORM
  • Tails

    Create websites with TailwindCSS

  • Blocks

    Design blocks for your website

  • Wave

    Start building the next great SAAS

  • Pines

    Alpine & Tailwind UI Library

  • Auth

    Plug'n Play Authentication for Laravel

  • Designer comingsoon

    Create website designs with AI

  • DevBlog comingsoon

    Blog platform for developers

  • Static

    Build a simple static website

  • SaaS Adventure

    21-day program to build a SAAS

Website Screenshots with Laravel

Created on August 9th, 2015

Below is the code used in the routes.php:

<?php

/*
|--------------------------------------------------------------------------
| Application Routes
|--------------------------------------------------------------------------
|
| Here is where you can register all of the routes for an application.
| It's a breeze. Simply tell Laravel the URIs it should respond to
| and give it the controller to call when that URI is requested.
|
*/

use JonnyW\PhantomJs\Client;

Route::get('/', function () {
    $url = Input::get('url');

    $client = Client::getInstance();
    $client->setBinDir('../bin');
    
    $request  = $client->getMessageFactory()->createCaptureRequest($url);
    $response = $client->getMessageFactory()->createResponse();
    
    $file = '../bin/file.jpg';
    
    $request->setCaptureFile($file);
    
    $client->send($request, $response);

    rename('../bin/file.jpg', 'screenshots/file.jpg');

    echo '<img src="screenshots/file.jpg" />';
});

You can also download the files from the Github repository here: https://github.com/thedevdojo/website-screenshot-with-laravel

Comments (0)

loading comments