Cisco IOS communications and configuration parsing library. PHP >= 7.4, PSR-4, PHPUnit.
composer install
vendor/bin/phpunit tests/ -v
vendor/bin/phpunit tests/ -v --coverage-clover coverage.xml --whitelist src/- Namespace:
Detain\CiscoParser\βsrc/ - Core:
src/CiscoParser.phpβ recursive config parser (parse_cisco_children,get_space_depth) - Loader:
src/CiscoLoader.phpβ connection/communication layer (SSH/telnet viaext-ssh2) - CLI:
bin/cisco_parser.phpβ reads a config file, invokesparse_cisco_children - Tests:
tests/ciscoTest.phpextendsPHPUnit\Framework\TestCase - CI:
.scrutinizer.ymlΒ·.travis.ymlΒ· coverage via clover tocoverage.xml - IDE:
.idea/β PhpStorm project configuration (inspectionProfiles/,cisco_parser.iml,deployment.xml)
- Tabs for indentation (see
.scrutinizer.ymluse_tabs: true) camelCaseproperties and parameters;UPPER_CASEconstants- One class per file; no closing
?> - PHPDoc on all public methods (
@param,@returnrequired) - Tests: extend
PHPUnit\Framework\TestCase; bootstrap via Composer autoloader parse_cisco_children(array $lines, int $x, int $depth)returns nested['command', 'arguments'?, 'children'?]arraysget_space_depth(array $lines, int $x)returns leading-space count as depth
namespace Detain\CiscoParser;
class CiscoParser {
public function myMethod(array $lines, $x = 0) {
// use mb_strlen / mb_substr / mb_strpos for multibyte safety
$depth = $this->get_space_depth($lines, $x);
$command = ltrim($lines[$x]);
return [];
}
}// tests/ciscoTest.php pattern
use PHPUnit\Framework\TestCase;
class myFeatureTest extends TestCase {
protected function setUp() {
$this->object = new \Detain\CiscoParser\CiscoParser();
}
public function testMyMethod() {
$this->assertEquals($expected, $this->object->myMethod($lines));
}
}# run single test
vendor/bin/phpunit tests/ciscoTest.php --filter testMyMethod -vext-ssh2is suggested, not required; guard SSH calls withextension_loaded('ssh2')- Commit messages: lowercase, descriptive (
fix depth parsing,add vlan parser)
Run caliber refresh before creating git commits to keep docs in sync with code changes.
After it completes, stage any modified doc files before committing:
caliber refresh && git add CLAUDE.md .claude/ .cursor/ .github/copilot-instructions.md AGENTS.md CALIBER_LEARNINGS.md 2>/dev/nullRead CALIBER_LEARNINGS.md for patterns and anti-patterns learned from previous sessions.
These are auto-extracted from real tool usage β treat them as project-specific rules.
Recommended default: claude-sonnet-4-6 with high effort (stronger reasoning; higher cost and latency than smaller models).
Smaller/faster models trade quality for speed and cost β pick what fits the task.
Pin your choice (/model in Claude Code, or CALIBER_MODEL when using Caliber with an API provider) so upstream default changes do not silently change behavior.
This project uses Caliber to keep AI agent configs in sync across Claude Code, Cursor, Copilot, and Codex.
Configs update automatically before each commit via caliber refresh.
If the pre-commit hook is not set up, run /setup-caliber to configure everything automatically.