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
|
||||
/*.phar
|
||||
/.spark
|
||||
/.spark.json
|
||||
/.spark.json
|
||||
/src/version
|
||||
/release
|
||||
|
@ -41,6 +41,8 @@ The advantage of writing your extensions as plugins:
|
||||
|
||||
- Object-oriented interface
|
||||
- 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
|
||||
|
||||
@ -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
|
||||
resources, resource types and plugins.
|
||||
|
||||
*Note: The script system need to be improved and revamped to support environment variables and such*
|
||||
|
||||
### Resources
|
||||
|
||||
Resources are wrappers around database connections and such, providing a cleaner
|
||||
interface to its innards.
|
||||
|
||||
|
||||
Resources are generally registered by plugins.
|
||||
|
@ -1,6 +1,12 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
|
||||
if (file_exists(__DIR__."/../src/version"))
|
||||
require_once __DIR__."/../src/version";
|
||||
else {
|
||||
define("APP_VERSION", "dev");
|
||||
}
|
||||
|
||||
require_once __DIR__."/../vendor/autoload.php";
|
||||
|
||||
$app = new Spark\SparkApplication();
|
||||
|
@ -125,9 +125,22 @@ class Environment
|
||||
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();
|
||||
|
||||
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" ];
|
||||
$config = [];
|
||||
while ($candidate = array_shift($candidates)) {
|
||||
|
@ -25,13 +25,13 @@ class SparkApplication extends Application
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct("Spark", "dev");
|
||||
parent::__construct("Spark", APP_VERSION);
|
||||
self::$instance = $this;
|
||||
|
||||
$this->resourceManager = new ResourceManager();
|
||||
$this->pluginManager = new PluginManager();
|
||||
|
||||
$this->environment = Environment::createFromDirectory();
|
||||
$this->environment = Environment::createFromDirectory(null, true);
|
||||
$this->environment->loadEnvironment();
|
||||
|
||||
$this->add(new Commands\RunCommand());
|
||||
|
Loading…
Reference in New Issue
Block a user