Updated readme, misc fixes
* Look for spark config in parent directories * Version tracking via src/version
This commit is contained in:
parent
c3e97ea4b1
commit
0d8844f499
4
.gitignore
vendored
4
.gitignore
vendored
@ -3,4 +3,6 @@
|
|||||||
/.phpunit.cache
|
/.phpunit.cache
|
||||||
/*.phar
|
/*.phar
|
||||||
/.spark
|
/.spark
|
||||||
/.spark.json
|
/.spark.json
|
||||||
|
/src/version
|
||||||
|
/release
|
||||||
|
@ -41,6 +41,8 @@ The advantage of writing your extensions as plugins:
|
|||||||
|
|
||||||
- Object-oriented interface
|
- Object-oriented interface
|
||||||
- Delayed evaluation of code, ensuring dependencies are loaded
|
- Delayed evaluation of code, ensuring dependencies are loaded
|
||||||
|
- Free autoloader! The namespace and path of the plugin class will be used to
|
||||||
|
set up a Psr-4 autoloader for your code.
|
||||||
|
|
||||||
### Scripts
|
### Scripts
|
||||||
|
|
||||||
@ -64,9 +66,11 @@ Using scripts is the simplest way to leverage Spark:
|
|||||||
`.php`-files are executed in-process, and as such have access to any registered
|
`.php`-files are executed in-process, and as such have access to any registered
|
||||||
resources, resource types and plugins.
|
resources, resource types and plugins.
|
||||||
|
|
||||||
|
*Note: The script system need to be improved and revamped to support environment variables and such*
|
||||||
|
|
||||||
### Resources
|
### Resources
|
||||||
|
|
||||||
Resources are wrappers around database connections and such, providing a cleaner
|
Resources are wrappers around database connections and such, providing a cleaner
|
||||||
interface to its innards.
|
interface to its innards.
|
||||||
|
|
||||||
|
Resources are generally registered by plugins.
|
||||||
|
@ -1,6 +1,12 @@
|
|||||||
#!/usr/bin/env php
|
#!/usr/bin/env php
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
if (file_exists(__DIR__."/../src/version"))
|
||||||
|
require_once __DIR__."/../src/version";
|
||||||
|
else {
|
||||||
|
define("APP_VERSION", "dev");
|
||||||
|
}
|
||||||
|
|
||||||
require_once __DIR__."/../vendor/autoload.php";
|
require_once __DIR__."/../vendor/autoload.php";
|
||||||
|
|
||||||
$app = new Spark\SparkApplication();
|
$app = new Spark\SparkApplication();
|
||||||
|
@ -125,9 +125,22 @@ class Environment
|
|||||||
SparkApplication::$instance->getPluginManager()->initializePlugins();
|
SparkApplication::$instance->getPluginManager()->initializePlugins();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function createFromDirectory(string|null $directory=null): Environment
|
public static function createFromDirectory(string|null $directory=null, bool $parents=false): Environment
|
||||||
{
|
{
|
||||||
$directory = $directory ?? getcwd();
|
$directory = $directory ?? getcwd();
|
||||||
|
|
||||||
|
if ($parents) {
|
||||||
|
$check = $directory;
|
||||||
|
while (!glob("{$check}/.spark*")) {
|
||||||
|
$p = dirname($check);
|
||||||
|
if ($p == $check) break;
|
||||||
|
$check = $p;
|
||||||
|
}
|
||||||
|
if (strlen($directory) > 1) {
|
||||||
|
$directory = $check;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$candidates = [ $directory . "/.spark.json", $directory . "/.spark/spark.json" ];
|
$candidates = [ $directory . "/.spark.json", $directory . "/.spark/spark.json" ];
|
||||||
$config = [];
|
$config = [];
|
||||||
while ($candidate = array_shift($candidates)) {
|
while ($candidate = array_shift($candidates)) {
|
||||||
|
@ -25,13 +25,13 @@ class SparkApplication extends Application
|
|||||||
|
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
parent::__construct("Spark", "dev");
|
parent::__construct("Spark", APP_VERSION);
|
||||||
self::$instance = $this;
|
self::$instance = $this;
|
||||||
|
|
||||||
$this->resourceManager = new ResourceManager();
|
$this->resourceManager = new ResourceManager();
|
||||||
$this->pluginManager = new PluginManager();
|
$this->pluginManager = new PluginManager();
|
||||||
|
|
||||||
$this->environment = Environment::createFromDirectory();
|
$this->environment = Environment::createFromDirectory(null, true);
|
||||||
$this->environment->loadEnvironment();
|
$this->environment->loadEnvironment();
|
||||||
|
|
||||||
$this->add(new Commands\RunCommand());
|
$this->add(new Commands\RunCommand());
|
||||||
|
Loading…
Reference in New Issue
Block a user