{"id":13464616,"url":"https://github.com/dweidner/laravel-goutte","last_synced_at":"2025-03-25T11:31:51.743Z","repository":{"id":31984526,"uuid":"35554920","full_name":"dweidner/laravel-goutte","owner":"dweidner","description":"Laravel Facade for Goutte, a simple PHP Web Scraper","archived":true,"fork":false,"pushed_at":"2024-01-25T20:28:20.000Z","size":39,"stargazers_count":453,"open_issues_count":0,"forks_count":75,"subscribers_count":15,"default_branch":"master","last_synced_at":"2025-02-19T11:50:17.688Z","etag":null,"topics":["facade","goutte","laravel"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dweidner.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2015-05-13T14:47:18.000Z","updated_at":"2024-11-09T15:07:28.000Z","dependencies_parsed_at":"2024-06-18T12:17:32.032Z","dependency_job_id":"dc601473-9a22-4da4-96c0-f74c336318a2","html_url":"https://github.com/dweidner/laravel-goutte","commit_stats":{"total_commits":47,"total_committers":11,"mean_commits":"4.2727272727272725","dds":0.4893617021276596,"last_synced_commit":"109415aed38a3cebfc0607d36ac02182b553ebf4"},"previous_names":[],"tags_count":14,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dweidner%2Flaravel-goutte","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dweidner%2Flaravel-goutte/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dweidner%2Flaravel-goutte/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dweidner%2Flaravel-goutte/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dweidner","download_url":"https://codeload.github.com/dweidner/laravel-goutte/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245454061,"owners_count":20617968,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["facade","goutte","laravel"],"created_at":"2024-07-31T14:00:47.454Z","updated_at":"2025-03-25T11:31:49.082Z","avatar_url":"https://github.com/dweidner.png","language":"PHP","funding_links":[],"categories":["All","PHP"],"sub_categories":[],"readme":"# Laravel Facade for Goutte\n\nThis repository implements a simple [ServiceProvider](https://laravel.com/docs/master/providers) that makes a singleton instance of the Goutte client easily accessible via a [Facade](https://laravel.com/docs/master/facades) in [Laravel](http://laravel.com). See [@FriendsOfPHP/Goutte](https://github.com/FriendsOfPHP/Goutte) for more information about the PHP web scraper and its interfaces.\n\n\u003e [!WARNING]  \n\u003e Goutte is deprecated and suggests to use the [`HttpBrowser` class](\nhttps://symfony.com/doc/current/components/browser_kit.html#making-external-http-requests)\nfrom the Symfony [BrowserKit](https://symfony.com/browser-kit) component as a direct repacement. This package was developed as a simple  integration for Laravel applications and thus will be deprecated as well.\n\n\n## Installation using [Composer](https://getcomposer.org/)\n\nIn 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.\n\n```sh\n$ cd ~/Sites/laravel-example-project\n$ composer require weidner/goutte\n```\n\nThis will add the following lines to your `composer.json` and download the project and its dependencies to your projects `./vendor` directory:\n\n```json\n// ./composer.json\n{\n    \"name\": \"weidner/laravel-goutte-test\",\n    \"description\": \"A dummy project used to test the Laravel Goutte Facade.\",\n\n    // ...\n\n    \"require\": {\n        \"php\": \"^7.2\",\n        \"laravel/framework\": \"^8\",\n        \"weidner/goutte\": \"^2\",\n        // ...\n    },\n\n    //...\n}\n```\n\n\n## Usage\n\nIn 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]`):\n\n```php\n// config/app.php\n\nreturn [\n\n    // ...\n\n    'providers' =\u003e [\n\n        // ...\n\n        /*\n         * Package Service Providers...\n         */\n        Weidner\\Goutte\\GoutteServiceProvider::class, // [1] This will register the Package in the laravel echo system\n\n        /*\n         * Application Service Providers...\n         */\n        App\\Providers\\AppServiceProvider::class,\n        App\\Providers\\AuthServiceProvider::class,\n        App\\Providers\\EventServiceProvider::class,\n        App\\Providers\\RouteServiceProvider::class,\n\n    ],\n\n    // ...\n\n    'aliases' =\u003e [\n\n        'App' =\u003e Illuminate\\Support\\Facades\\App::class,\n        'Artisan' =\u003e Illuminate\\Support\\Facades\\Artisan::class,\n\n        // ...\n\n        'Goutte' =\u003e Weidner\\Goutte\\GoutteFacade::class, // [2] It will register as an alias for the Goutte facade\n        'Hash' =\u003e Illuminate\\Support\\Facades\\Hash::class,\n\n        // ...\n    ],\n\n];\n\n```\n\nNow you should be able to use the facade within your application. Laravel will autoload the corresponding classes once you use the registered alias.\n\n```php\n// routes/web.php\n\nRoute::get('/', function() {\n    $crawler = Goutte::request('GET', 'https://duckduckgo.com/html/?q=Laravel');\n    $crawler-\u003efilter('.result__title .result__a')-\u003eeach(function ($node) {\n      dump($node-\u003etext());\n    });\n    return view('welcome');\n});\n```\n\n*TIP:* If you retrieve a \"Class 'Goutte' not found\"-Exception try to update the autoloader by running `composer dump-autoload` in your project root.\n\n*TIP:* You can use the package with [Lumen](https://lumen.laravel.com/) as well. Register the `GoutteServiceProvider` in `bootstrap/app.php` and provide the missing path to your configuration directory in your `AppServiceProvider` (ref [\\#34](https://github.com/dweidner/laravel-goutte/issues/34/)).\n\n## Configuration\n\nYou can customize the default request options to apply to each request of the client. Copy the default configuration to your application directory first:\n\n```sh\nphp artisan vendor:publish --provider=\"Weidner\\Goutte\\GoutteServiceProvider\"\n```\n\nOpen the created file in the `config/goutte.php` and customize the configuration options to your liking.\n\n```php\n\u003c?php\n\nreturn [\n    'client' =\u003e [\n        'max_redirects' =\u003e 0,\n    ],\n];\n```\n\nHave a look into the [Symfony Http Client Documentation](https://symfony.com/doc/current/http_client.html) for a full list of available options.\n\n## Version Constraint\n\n| Release            | Supported Versions |\n|--------------------|--------------------|\n| Laravel Goutte 2.3 | Laravel 8/9/10     |\n| Laravel Goutte 2.2 | Laravel 8/9        |\n| Laravel Goutte 2.0 | Laravel 8          |\n| Laravel Goutte 1.6 | Laravel 5/6/7      |\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdweidner%2Flaravel-goutte","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdweidner%2Flaravel-goutte","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdweidner%2Flaravel-goutte/lists"}