weidner/goutte
最新稳定版本:2.3.0
Composer 安装命令:
composer require weidner/goutte
包简介
Laravel Facade for Goutte, a simple PHP Web Scraper
README 文档
README
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.
Warning
Goutte is deprecated and suggests to use the HttpBrowser class
from the Symfony BrowserKit component as a direct repacement. This package was developed as a simple integration for Laravel applications and thus will be deprecated as well.
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.3 | Laravel 8/9/10 |
| Laravel Goutte 2.2 | Laravel 8/9 |
| Laravel Goutte 2.0 | Laravel 8 |
| Laravel Goutte 1.6 | Laravel 5/6/7 |
weidner/goutte 适用场景与选型建议
weidner/goutte 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1.55M 次下载、GitHub Stars 达 453, 最近一次更新时间为 2026 年 01 月 04 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「goutte」 「laravel」 「weidner」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 weidner/goutte 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 weidner/goutte 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 weidner/goutte 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Simple, intuitive integration testing with PHPUnit.
Crawl your own website with various clients for SEO and indexing purposes.
A Laravel 5 service provider for Goutte - Made by artisan for artisans.
Laravel Facade for Goutte, a simple PHP Web Scraper
Alfabank REST API integration
Laravel 5 package for Goutte, a simple PHP Web Scraper
统计信息
- 总下载量: 1.55M
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 459
- 点击次数: 26
- 依赖项目数: 3
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-01-04