Skip to content

Commit 2c15466

Browse files
committed
Adding an autoload file
Enable using the package without composer
1 parent 43216f6 commit 2c15466

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ All Notable changes to `bakame/http-strucured-fields` will be documented in this
88

99
- `Item::fromPair` named constructor to create a new instance from a pair expressed as an array list with two values.
1010
- `Parameters::sanitize` ensure the container always contains only Bare Items.
11+
- `autoload.php` script to allow non composer application to load the package
1112

1213
### Fixed
1314

autoload.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
spl_autoload_register(function (string $className): void {
6+
7+
$prefix = 'Bakame\Http\StructuredFields\\';
8+
if (!str_starts_with($className, $prefix)) {
9+
return;
10+
}
11+
12+
$file = __DIR__.'/src/'.str_replace('\\', '/', substr($className, strlen($prefix))).'.php';
13+
if (is_readable($file)) {
14+
require $file;
15+
}
16+
});

0 commit comments

Comments
 (0)