Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 11 additions & 14 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,20 @@
"description": "Symfony bundle for roach-php/core",
"type": "symfony-bundle",
"require": {
"php": ">= 8.0",
"roach-php/core": "~1.1.0",
"symfony/config": "^6.0",
"symfony/dependency-injection": "^6.0",
"symfony/http-kernel": "^6.0",
"symfony/console": "^6.0",
"symfony/serializer": "^6.0"
"php": ">= 8.2",
"roach-php/core": "^3.2",
"symfony/config": "^7.0",
"symfony/dependency-injection": "^7.0",
"symfony/http-kernel": "^7.0",
"symfony/console": "^7.0",
"symfony/serializer": "^7.0"
},
"require-dev": {
"roave/security-advisories": "dev-latest",
"symfony/phpunit-bridge": "^6.0",
"symfony/var-dumper": "^6.0",
"symfony/framework-bundle": "^6.0",
"symfony/maker-bundle": "^1.37",
"vimeo/psalm": "^4.21",
"psalm/plugin-symfony": "^3.1",
"psalm/plugin-phpunit": "^0.16.1"
"symfony/phpunit-bridge": "^7.0",
"symfony/var-dumper": "^7.0",
"symfony/framework-bundle": "^7.0",
"symfony/maker-bundle": "^1.68"
},
"license": "MIT",
"autoload": {
Expand Down
8 changes: 4 additions & 4 deletions src/Command/RunSpiderCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,6 @@

final class RunSpiderCommand extends Command
{
protected static $defaultName = 'roach:run';

protected static $defaultDescription = 'Run the provided spider';

/** @var array<class-string<\RoachPHP\Spider\SpiderInterface>, array<string>> */
private array $spiderNames;

Expand All @@ -45,6 +41,10 @@ public function __construct(private ServiceLocator $serviceLocator, private Seri

protected function configure(): void
{
$this
->setName('roach:run')
->setDescription('Run the provided spider');

$spiderArgDescription = "Spider class name\nSupport spiders:\n";

foreach ($this->spiderNames as $className => $aliases) {
Expand Down
9 changes: 4 additions & 5 deletions src/Normalizer/ItemNormalizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,16 @@
namespace Nelexa\RoachPhpBundle\Normalizer;

use RoachPHP\ItemPipeline\ItemInterface;
use Symfony\Component\Serializer\Normalizer\CacheableSupportsMethodInterface;
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;

class ItemNormalizer implements NormalizerInterface, CacheableSupportsMethodInterface
class ItemNormalizer implements NormalizerInterface
{
public function hasCacheableSupportsMethod(): bool
public function getSupportedTypes(?string $format): array
{
return true;
return [ItemInterface::class];
}

public function supportsNormalization(mixed $data, ?string $format = null): bool
public function supportsNormalization(mixed $data, ?string $format = null, array $context = []): bool
{
return $data instanceof ItemInterface;
}
Expand Down
17 changes: 17 additions & 0 deletions src/Resources/config/services.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,23 @@
;
$services->set(\RoachPHP\Downloader\Middleware\RobotsTxtMiddleware::class);
$services->set(\RoachPHP\Downloader\Middleware\UserAgentMiddleware::class);
// New in roach-php/core 3.x: drops responses with unallowed HTTP status.
// Configure per spider via the "handleStatus" option.
$services
->set(\RoachPHP\Downloader\Middleware\HttpErrorMiddleware::class)
->args([
service('roach_php.logger'),
])
;
// New in roach-php/core 3.x: assigns proxies to requests.
// Configure per spider via the "proxy" or "loader" options.
$services
->set(\RoachPHP\Downloader\Middleware\ProxyMiddleware::class)
->args([
service('service_container'),
service('roach_php.logger'),
])
;

// Extensions
$services
Expand Down
Loading