yii2-ridb-campgrounds US federal campgrounds (Recreation.gov RIDB) for Yii 2: filter, nearest, GridView and console

  1. Requirements
  2. Installation
  3. Usage
  4. Tests
  5. Credits

US federal campgrounds for Yii 2: filter 3,948 Recreation.gov campgrounds by state, agency, amenities and RV length, find the nearest ones to a point, show them in a GridView, export GeoJSON for a map, or search them from the console. No API key, no network request and no database: the data (the public RIDB export of 2026-11-16) ships with the extension.

Requirements

  • Yii 2.0.45 or later, PHP 8.0 or later

Installation

The package is installed from its GitHub repository with Composer:

"repositories": [
    { "type": "vcs", "url": "https://github.com/campkitchenus-maker/yii2-ridb-campgrounds" }
]
composer require campkitchenus/yii2-ridb-campgrounds

Or download the release zip and autoload src/ under the campkitchenus\campgrounds namespace.

Usage

'components' => [
    'campgrounds' => ['class' => \campkitchenus\campgrounds\Campgrounds::class],
],
$cg = Yii::$app->campgrounds;

$rows = $cg->find(['states' => ['CA', 'OR'], 'amenities' => ['rv', 'electric'], 'minRigFt' => 35]);
$near = $cg->nearest(37.7459, -119.5332, 5, ['reservable' => true]); // each row gets distanceMi

echo \yii\grid\GridView::widget([
    'dataProvider' => $cg->dataProvider(['states' => 'UT', 'amenities' => ['tent']]),
    'columns' => ['name', 'agency', 'sites', 'maxRigFt'],
]);

Filters: states, agencies, reservable, minSites, amenities (tent, rv, electric, water, firePit, picnicTable, pets, accessible), minRigFt, includeUnknownRig, bbox and q (name search). Unknown filters or amenities throw an InvalidArgumentException instead of returning nothing.

Console (controllerMap entry campgrounds):

yii campgrounds/search --state=CA --amenities=rv,electric --min-rig-ft=40 --limit=5
yii campgrounds/search --near=44.428,-110.588 --limit=3 --format=csv

Tests

PHPUnit: 12 tests, 151 assertions, run on Yii 2.0.55 with PHP 8.5, plus the console commands and a GridView page in a Yii app.

Credits

Data Source: Recreation.gov (show Campgrounds::ATTRIBUTION in your UI); not affiliated with or endorsed by Recreation.gov. The same data drives the campground map on campkitchen.us. Made by Camp Kitchen US with help from an AI assistant, then tested as described above. MIT License.

0 0
1
0
Yii Version: 2.0.*
License: MIT
Category: Others
    Created: Nov 18, 2026
    Github Repository

    Downloads

    show all