All Projects → dweidner → Laravel Goutte

dweidner / Laravel Goutte

Licence: mit
Laravel Facade for Goutte, a simple PHP Web Scraper

Labels

Projects that are alternatives of or similar to Laravel Goutte

Jianzhi V2
基于laravel5.5跟Vue2前后端分离的兼职平台
Stars: ✭ 327 (-2.97%)
Mutual labels:  laravel
Laravel Glide
Easily convert images with Glide
Stars: ✭ 333 (-1.19%)
Mutual labels:  laravel
Verta
تاریخ شمسی برای لاراول 5 , 6 , 7 , 8 تاریخ جلالی , تاریخ شمسی, پکیج شمسی, تبدیل تاریخ میلادی به شمسی
Stars: ✭ 335 (-0.59%)
Mutual labels:  laravel
Awesome Laravel Education
A curated list of resources for learning about the Laravel PHP Framework
Stars: ✭ 327 (-2.97%)
Mutual labels:  laravel
Scout Extended
Scout Extended: The Full Power of Algolia in Laravel
Stars: ✭ 330 (-2.08%)
Mutual labels:  laravel
Laravel Forum
A minimal forum package designed for quick and easy integration in Laravel projects
Stars: ✭ 335 (-0.59%)
Mutual labels:  laravel
Shadowfax
Run Laravel on Swoole.
Stars: ✭ 325 (-3.56%)
Mutual labels:  laravel
Candy Api
GetCandy E-Commerce API
Stars: ✭ 339 (+0.59%)
Mutual labels:  laravel
Laravel Desktop Notifier
💻 Send notifications to your desktop from your Laravel Artisan Commands. An JoliNotif wrapper for Laravel.
Stars: ✭ 333 (-1.19%)
Mutual labels:  laravel
Laravel Source Analysis
详解 laravel 源码
Stars: ✭ 338 (+0.3%)
Mutual labels:  laravel
Seat
🌀✳️ SeAT: A Simple, EVE Online API Tool and Corporation Manager
Stars: ✭ 324 (-3.86%)
Mutual labels:  laravel
Jetstrap
A Laravel 8 package to easily switch TailwindCSS resources generated by Laravel Jetstream and Breeze to Bootstrap 4.
Stars: ✭ 320 (-5.04%)
Mutual labels:  laravel
Laravel Apz
The guide to build a Laravel 5.2 app from a to z.
Stars: ✭ 336 (-0.3%)
Mutual labels:  laravel
Generator
Laravel 5.3+ Scaffold Generator, Support both bootstrap and Semantic UI
Stars: ✭ 327 (-2.97%)
Mutual labels:  laravel
Yaldash
👻 It's never been easier to build and customize admin panels. Yah! yaldash is a beautifully designed administration panel for Laravel.
Stars: ✭ 338 (+0.3%)
Mutual labels:  laravel
Laravel Queueable Action
Queueable actions in Laravel
Stars: ✭ 326 (-3.26%)
Mutual labels:  laravel
Validator Docs
Validação de CPF, CNPJ, CNH, NIS, Título Eleitoral e Cartão Nacional de Saúde com Laravel.
Stars: ✭ 334 (-0.89%)
Mutual labels:  laravel
Laravel Referer
Remember a visitor's original referer
Stars: ✭ 339 (+0.59%)
Mutual labels:  laravel
Weeshop
优雅易用的微信小程序商城,PHP商城。 基于Laravel的基因,来自Symfony的底层技术,来自Drupal Commerce的核心技术,由Drupal中国开源社区维护。QQ群:714023327
Stars: ✭ 337 (+0%)
Mutual labels:  laravel
Screeenly
📸 Screenshot as a Service
Stars: ✭ 336 (-0.3%)
Mutual labels:  laravel

Laravel Facade for Goutte

This repository implements a simple ServiceProvider that makes a singleton instance of the Goutte client easily accessible via a Facade in Laravel. See @FriendsOfPHP/Goutte for more information about the PHP web scraper and its interfaces.

Installation using Composer

In your terminal application move to the root directory of your laravel project using the cd command and require the project as a dependency using composer.

$ cd ~/Sites/laravel-example-project
$ composer require weidner/goutte

This will add the following lines to your composer.json and download the project and its dependencies to your projects ./vendor directory:

// ./composer.json
{
    "name": "weidner/laravel-goutte-test",
    "description": "A dummy project used to test the Laravel Goutte Facade.",

    // ...

    "require": {
        "php": "^7.2",
        "laravel/framework": "^8",
        "weidner/goutte": "^2",
        // ...
    },

    //...
}

Usage

In order to use the static interface we first have to customize the application configuration to tell the system where it can find the new service. Open the file config/app.php in the editor of your choice and add the following lines ([1], [2]):

// config/app.php

return [

    // ...

    'providers' => [

        // ...

        /*
         * Package Service Providers...
         */
        Weidner\Goutte\GoutteServiceProvider::class, // [1] This will register the Package in the laravel echo system

        /*
         * Application Service Providers...
         */
        App\Providers\AppServiceProvider::class,
        App\Providers\AuthServiceProvider::class,
        App\Providers\EventServiceProvider::class,
        App\Providers\RouteServiceProvider::class,

    ],

    // ...

    'aliases' => [

        'App' => Illuminate\Support\Facades\App::class,
        'Artisan' => Illuminate\Support\Facades\Artisan::class,

        // ...

        'Goutte' => Weidner\Goutte\GoutteFacade::class, // [2] It will register as an alias for the Goutte facade
        'Hash' => Illuminate\Support\Facades\Hash::class,

        // ...
    ],

];

Now you should be able to use the facade within your application. Laravel will autoload the corresponding classes once you use the registered alias.

// routes/web.php

Route::get('/', function() {
    $crawler = Goutte::request('GET', 'https://duckduckgo.com/html/?q=Laravel');
    $crawler->filter('.result__title .result__a')->each(function ($node) {
      dump($node->text());
    });
    return view('welcome');
});

TIP: If you retrieve a "Class 'Goutte' not found"-Exception try to update the autoloader by running composer dump-autoload in your project root.

TIP: You can use the package with Lumen as well. Register the GoutteServiceProvider in bootstrap/app.php and provide the missing path to your configuration directory in your AppServiceProvider (ref #34).

Configuration

You can customize the default request options to apply to each request of the client. Copy the default configuration to your application directory first:

php artisan vendor:publish --provider="Weidner\Goutte\GoutteServiceProvider"

Open the created file in the config/goutte.php and customize the configuration options to your liking.

<?php

return [
    'client' => [
        'max_redirects' => 0,
    ],
];

Have a look into the Symfony Http Client Documentation for a full list of available options.

Version Constraint

Release Supported Versions
Laravel Goutte 2.x Laravel 8
Laravel Goutte 1.6 Laravel 5/6/7
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].