Roach-example-project - Example project to demonstrate how to use RoachPHP in a Laravel project.

Overview

Example repository to illustrate how to use roach-php/laravel in a Laravel app.

Check app/Spiders/FussballdatenSpider.php for an example spider that crawls yesterday’s football matches from https://fussballdaten.de and imports new ones into a SQLite database.

Set the LOG_CHANNEL to stdout in your .env file to have Roach log to stdout during a spider’s run.

Run php artisan scrape:fussballdaten to run the spider.

You might also like...
The game is implemented as an example of scalable and high load architecture combined with modern software development practices
The game is implemented as an example of scalable and high load architecture combined with modern software development practices

Crossword game The game is implemented as an example of scalable and high load architecture combined with modern software development practices Exampl

Simple laravel5 example for tutorial

Laravel 5 example For Laravel 5.3 improved version look at this repository. Laravel 5 example is a tutorial application for Laravel 5.2 (in french the

TYPO3 Camp Rhein-Ruhr - Sitepackage Example

EXT:t3crr_sitepackage - A example TYPO3 Sitepackage Extension This extension was used in the T3CRR Talk "Sitepackage Einführung" in 2021! Notice Bewar

This example shows how to estimate pi, using generated random numbers that uniformly distributed.
This example shows how to estimate pi, using generated random numbers that uniformly distributed.

php-estimatepi This example shows how to estimate pi, using generated random numbers that uniformly distributed. Every pair of numbers produced will b

Phalcon Mooc an example API + Front End with automated tests
Phalcon Mooc an example API + Front End with automated tests

NovaMooc - a Phalcon project A Mooc project developed with Phalcon, a PHP framework. Key Features • How To Use • Contributing • Credits • License Key

This repository aims to build a fairly complete CI/CD example using GitHub workflows and actions.
This repository aims to build a fairly complete CI/CD example using GitHub workflows and actions.

CI/CD example This repository aims to build a fairly complete CI/CD example using GitHub workflows and actions. Keep in mind that the toolset used in

A list of documentation and example code to access the University of Florida's public (undocumented) API

uf_api A list of documentation and example code to access the University of Florida's public (undocumented) API Courses Gym Common Data (admissions an

This is an example app demonstrating how to deploy a php app to runway.

Runway Example php App This is an example app demonstrating how to deploy a php app to runway. clone this repo, and navigate into that directory runwa

In order to use the Korean Language on your Magento 2 store, it is time to start with Magento 2 Korean Language Pack in the set of informative documentations by Mageplaza. Magento 2 Korean Language Package is published by Magento 2 Translation Project at Crowdin, so all phrases will be replaced by the Korean language according to the contribution to that project. Please following up the guides in this post to convert the language with ease!
Comments
  • No itemProcessor after pulling roach php

    No itemProcessor after pulling roach php

    I'm getting started with roach-php/laravel and using this project as a guideline. After installing the package. I can't seem to find ItemProcessor in the package. But it exist on in this example project. I would be grateful for more guidance.

    opened by iamkarsoft 3
  • Can't drop a request with RequestMiddlewareInterface

    Can't drop a request with RequestMiddlewareInterface

    Hello,

    I have a problem when I want to return a drop from a Spider Middleware, it is not fired. I feel that the handleRequest method is not fired too. Can you help me please ?

    Code

    Spiders/Spider1.php

    <?php
    
    namespace App\Spiders;
    
    use App\Spiders\Processors\SaveJobToDatabaseProcessor;
    use App\Spiders\SpiderMiddleware\CheckJobAlreadyExistsMiddleware;
    use Generator;
    use RoachPHP\Downloader\Middleware\RequestDeduplicationMiddleware;
    use RoachPHP\Downloader\Middleware\UserAgentMiddleware;
    use RoachPHP\Extensions\LoggerExtension;
    use RoachPHP\Extensions\StatsCollectorExtension;
    use RoachPHP\Http\Response;
    use RoachPHP\Spider\BasicSpider;
    use RoachPHP\Spider\ParseResult;
    
    class Spider1 extends BasicSpider
    {
        public array $startUrls = [
            'https://roach-php.dev/docs/spiders'
        ];
    
        public array $downloaderMiddleware = [
            RequestDeduplicationMiddleware::class,
            [UserAgentMiddleware::class, ['userAgent' => 'Mozilla/5.0 (compatible; RoachPHP/0.1.0)']],
        ];
    
        public array $spiderMiddleware = [
            CheckJobAlreadyExistsMiddleware::class,
        ];
    
        public array $itemProcessors = [
            SaveJobToDatabaseProcessor::class,
        ];
    
        public array $extensions = [
            LoggerExtension::class,
            StatsCollectorExtension::class,
        ];
    
        public int $concurrency = 2;
    
        public int $requestDelay = 1;
    
        /**
         * @return Generator<ParseResult>
         */
        public function parse(Response $response): \Generator
        {
            $title = $response->filter('h1')->text();
    
            $content = $response
                ->filter('main > div:nth-child(2) p:first-of-type')
                ->text();
    
            yield $this->item([
                'id' => '123456',
                'title' => $title,
                'content' => $content,
                'contract_type' => 'CDI',
            ]);
        }
    }
    

    Spiders/SpiderMiddleware/CheckJobAlreadyExistsMiddleware.php

    <?php
    
    namespace App\Spiders\SpiderMiddleware;
    
    use App\Models\Job;
    use RoachPHP\Http\Request;
    use RoachPHP\Http\Response;
    use RoachPHP\Support\Configurable;
    use RoachPHP\Spider\Middleware\RequestMiddlewareInterface;
    
    class CheckJobAlreadyExistsMiddleware implements RequestMiddlewareInterface
    {
        use Configurable;
    
        public function handleRequest(Request $request, Response $response): Request
        {
            return $request->drop('This never happens');
        }
    }
    

    Logs

    [2022-10-05 16:19:14] local.INFO: Run starting  
    [2022-10-05 16:19:14] local.INFO: Dispatching request {"uri":"https://roach-php.dev/docs/spiders"} 
    [2022-10-05 16:19:15] local.INFO: Item scraped {"id":"123456","title":"Spiders","content":"Basic Concepts","contract_type":"CDI"} 
    [2022-10-05 16:19:15] local.INFO: Run statistics {"duration":"00:00:00","requests.sent":1,"requests.dropped":0,"items.scraped":1,"items.dropped":0} 
    [2022-10-05 16:19:15] local.INFO: Run finished
    

    As you can see, "requests.dropped" is 0 instead of 1

    Packages version

    laravel/framework v9.34.0 roach-php/core 1.1.1 roach-php/laravel 1.0.0

    opened by David-YesWeDev 1
Owner
Kai Sassnowski
Hi I'm Kai. I live in Munich. I like D&D. I work for @wycomco. I built https://utgars-chronicles.app
Kai Sassnowski
A quick naked theme to demonstrate how easy it is to support Gutenberg using ACF blocks

ACF Gutenberg Demo Theme A quick naked theme to demonstrate how easy it is to support Gutenberg using ACF blocks demo.mp4 Files I have found a useful

Stirtingale 1 Oct 28, 2021
A collection of samples that demonstrate how to call Google Cloud services from PHP.

PHP Docs Samples A collection of samples that demonstrate how to call Google Cloud services from PHP. See our other Google Cloud Platform github repos

Google Cloud Platform 875 Dec 29, 2022
A collection of samples that demonstrate how to call Google Cloud services from PHP.

PHP Docs Samples A collection of samples that demonstrate how to call Google Cloud services from PHP. See our other Google Cloud Platform github repos

Google Cloud Platform 796 Dec 22, 2021
This example shows how to use Anychart library with the PHP programming language, Laravel framework and MySQL database.

PHP basic template This example shows how to use Anychart library with the PHP programming language, Laravel framework and MySQL database. Running To

AnyChart Integrations and Templates 23 Jul 17, 2022
My intention with this app is that new developers can have a concrete application with Laravel + VueJS where they can use it as example to learn the right way

My intention with this app is that new developers can have a concrete application with Laravel + VueJS where they can use it as example to learn the right way, implementing the best practices possible and at the same time learn how TDD is done. So this will be an example application but completely usable for any similar case.

Eng Hasan Hajjar 2 Sep 30, 2022
HTMX example app that demonstrates how to use HTMX to add javascript interactivity to a serverside rendered PHP app

HTMX examle app This demo app demonstrates how to use HTMX to transform a server side rendered PHP app into a more 'interactive' app with AJAX request

Alexander Morland 3 Dec 11, 2022
A sample project to showcase a real world example and benchmarks for crowphp

CrowPHP Sample project This project is to showcase an example of how a real world project might look like. It has two basic endpoints to show-case the

Crow PHP 3 Aug 16, 2021
my personal example of Laravel clean architecture

what is this repo about Clean Architect Laravel ###run we assume docker desktop is up and running open up a terminal cd project directory run "cp .env

Sadegh Salari 37 Dec 23, 2022
Laravel & Solana Phantom wallet example built with Bootstrap, JQuery. App connects to Phantom wallet and fetching publicKey and balance information.

Phantom Wallet Authentication Example Laravel & Solana ($SOL) Phantom wallet example built with Bootstrap, JQuery. This is a Web 3.0 app that connects

Solanacraft 3 Oct 19, 2022
Michael Pratt 307 Dec 23, 2022