Skip to content

Commit c3c5167

Browse files
committed
Add automatic initialization to simplify usage of this library
1 parent 7349b8c commit c3c5167

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

bootstrap.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?php
2+
/**
3+
* Native matrix library
4+
*
5+
* @copyright Copyright 2019, Lisachenko Alexander <lisachenko.it@gmail.com>
6+
*
7+
* This source file is subject to the license that is bundled
8+
* with this source code in the file LICENSE.
9+
*/
10+
declare(strict_types=1);
11+
12+
use Native\Type\Matrix;
13+
use ZEngine\Core;
14+
use ZEngine\Reflection\ReflectionClass as ReflectionClassEx;
15+
16+
// We can not be sure that ZEngine library will be initialized first, so check if it present
17+
if (!class_exists(Core::class, false)) {
18+
Core::init();
19+
}
20+
21+
// Activate extensions for the Matrix class as it provides
22+
$matrixClassReflection = new ReflectionClassEx(Matrix::class);
23+
$matrixClassReflection->installExtensionHandlers();

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
"autoload": {
1717
"psr-4" : {
1818
"Native\\Type\\" : "src/"
19-
}
19+
},
20+
"files": ["bootstrap.php"]
2021
}
2122
}

0 commit comments

Comments
 (0)