Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><strong>If each crawler exists for a different reason</strong>, you can use arbitrary names for your instances, for example:</p> <pre><code>App::bind('crawler.allArticles', 'PageCrawler'); App::bind('crawler.latestArticles', 'FeedCrawler'); </code></pre> <p>For the controller:</p> <pre><code>App::bind('CrawlerController', function($app) { return new CrawlerController( App::make('crawler.allArticles'), App::make('crawler.latestArticles') ); }); </code></pre> <p>Your controller code would then use each crawler differently:</p> <pre><code>public function showLatestArticlesAction() $latestArticles = $this-&gt;latestArticlesCrawler-&gt;crawl(); // ... } public function showAllArticlesAction() $allArticles = $this-&gt;allArticlesCrawler-&gt;crawl(); // ... } </code></pre> <hr> <p><strong>If you just have a list of crawlers where each is used for the same thing</strong>, you probably want to do something like:</p> <pre><code>App::bind('crawlers', function($app) { return [ App::make('PageCrawler'), App::make('FeedCrawler'), ]; }); </code></pre> <p>In your controller, you'll get a list of "crawlers" by configuring it like so:</p> <pre><code>App::bind('CrawlerController', function($app) { return new CrawlerController(App::make('crawlers')); }); </code></pre> <p>Your controller code could be something like this:</p> <pre><code>public function showArticlesAction() $allArticles = array(); foreach ($this-&gt;crawlers as $crawler) { $allArticles = array_merge($allArticles, $this-&gt;crawler-&gt;crawl()); } // ... } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload