new pisilinux web sites

This commit is contained in:
Erkan IŞIK
2026-07-01 16:44:17 +03:00
commit b58488b586
21740 changed files with 2066209 additions and 0 deletions
+611
View File
@@ -0,0 +1,611 @@
<?php namespace ZN\Console;
/**
* ZN PHP Web Framework
*
* "Simplicity is the ultimate sophistication." ~ Da Vinci
*
* @package ZN
* @license MIT [http://opensource.org/licenses/MIT]
* @author Ozan UYKUN [ozan@znframework.com]
*/
use Throwable;
use ZN\Base;
use ZN\Config;
use ZN\Request;
use ZN\Buffering;
use ZN\Filesystem;
use ZN\Protection\Json;
use ZN\Helpers\Converter;
use ZN\ErrorHandling\Errors;
use ZN\ErrorHandling\Exceptions;
/**
* @codeCoverageIgnore
*/
class Async
{
/**
* Keeps process ID.
*
* @var string $procId
*/
protected static $procId = '';
/**
* Keeps process directory.
*
* @var string $procDir
*/
protected static $procDir = FILES_DIR;
/**
* Keeps soket URI.
*
* @var string $socket
*/
protected static $socketURI = '';
/**
* Keeps socket success
*
* @var string $success
*/
protected static $success = '';
/**
* Keeps socket error
*
* @var string $error
*/
protected static $error = '';
/**
* Sets process directory.
*
* @param string $directory
*
* @return self
*/
public static function setProcDirectory(string $directory) : Async
{
self::$procDir = $directory;
return new self;
}
/**
* Sets socket URI.
*
* @param string $directory
*
* @return self
*/
public static function setSocketURI(string $socketURI) : Async
{
self::$socketURI = $socketURI;
return new self;
}
/**
* Get process data.
*
* @param string $procId = current-process
*
* @return array
*/
public static function getData(string $procId = '') : array
{
$procFile = self::getProcFile($procId);
if( is_file($procFile) )
{
return Json::decodeArray(file_get_contents($procFile));
}
return [];
}
/**
* Get process Id.
*/
public static function getProcId() : string
{
return self::$procId;
}
/**
* Run command
*
* @param string $command
* @param array $data = []
* @param string $name = NULL
*/
public static function run(string $command, array $data = [], ?string $name = NULL) : string
{
self::$procId = $procId = self::$procDir . ($uniq = $name ? preg_replace('/\W+/', '', $name) : uniqid());
$processor = Config::default('ZN\Prompt\PromptDefaultConfiguration')::get('Services', 'processor');
if( ! file_exists($processor['path']) )
{
$path = 'php';
}
else
{
$path = $processor['path'];
}
$open = proc_open($path . ' zerocore ' . $command . ' "' . $procId . '"', [], $arr);
$data['status'] = proc_get_status($open);
$data['status']['run'] = $command;
$data['status']['file'] = $uniq;
$data['status']['path'] = self::$procId;
file_put_contents($procId, Json::encode($data));
return $procId;
}
/**
* List
*
* @return array
*/
public static function list() : array
{
$processList = [];
foreach( Filesystem::getFiles(self::$procDir, NULL, true) as $file )
{
$processList[] = self::getData($file);
}
return $processList;
}
/**
* Close proc
*
* @param string $procId = current-process
*
* @return string|false
*/
public static function close(string $procId = '')
{
if( $pid = self::getData($procId)['status']['pid'] ?? NULL )
{
self::remove($procId);
return self::closeProcess($pid);
}
return false;
}
/**
* Close All Process
*
*/
public static function closeAll()
{
foreach( self::list() as $proc )
{
if( isset($proc['file']) )
{
self::close($proc['file']);
}
}
}
/**
* Is Exists
*
* @param string $procId = current-process
*
* @return bool
*/
public static function isExists(string $procId = '') : bool
{
$procFile = self::getProcFile($procId);
return is_file($procFile);
}
/**
* Command process
*
* @param string $procId
* @param callback $callable
* @param bool $displayError = false
*/
public static function process(string $procId, callable $callable, bool $displayError = false) : void
{
self::$procId = $procId;
$data = self::getData($procId);
try
{
$callable($data, $procId);
}
catch( Throwable $e )
{
if( $displayError )
{
$error =
[
'code' => $e->getCode(),
'message' => $e->getMessage(),
'file' => $e->getFile(),
'line' => $e->getLine(),
'trace' => $e->getTrace()
];
self::report($error, 'error');
}
}
self::close();
}
/**
* Remove process ID
*
* @param string $procId = current-process
*
* @return bool
*/
public static function remove(string $procId = '') : bool
{
$procFile = self::getProcFile($procId);
if( is_file($procFile) )
{
return unlink($procFile);
}
return false;
}
/**
* Create report
*
* @param array $data
*
* @return int
*/
public static function report(array $data, string $suffix = 'report') : int
{
return file_put_contents(self::$procId . '-' . $suffix, Json::encode($data));
}
/**
* Output
*
* @param array $data
*
* @return int
*/
public static function output(array $data) : int
{
return self::report($data, 'output');
}
/**
* Creates socket
*/
public static function socket()
{
$originFile = self::getProcFile($_POST['procId']);
$procFile = Base::suffix($originFile, '-output');
if( is_file($originFile) )
{
echo json_encode(['status' => 'processing']);
}
else if( is_file($procFile) )
{
echo file_get_contents($procFile);
unlink($procFile);
}
else
{
echo json_encode([]);
}
exit;
}
/**
* Sets socket success
*
* @param callable $callback
*/
public static function success(callable $callable)
{
self::$success = $callable;
return new self;
}
/**
* Sets socket error
*
* @param callable $callback
*/
public static function error(callable $callable)
{
self::$error = $callable;
return new self;
}
/**
* @param string $procId
* @param int $time = 1000
*
* @return string
*/
public static function listen($procId, int $time = 1000) : string
{
$var = 'socket' . uniqid();
$procData = ( is_scalar($procId) ? '"' . str_replace(self::$procDir, '', $procId) . '"' : Buffering\Callback::do($procId) );
$return =
'
var ' . $var . ' = setInterval(function()
{
$.ajax
({
url: "' . Request::getSiteURL(self::$socketURI) . '",
type: "post",
dataType: "json",
data: {procId: ' . $procData . '},
success: function(data)
{
' . (self::$success ? Buffering\Callback::do(self::$success) : '') . '
if( data.status != "processing" )
{
clearInterval(' . $var . ');
}
},
error: function(data)
{
' . (self::$error ? Buffering\Callback::do(self::$error) : '') . '
}
})
}, ' . $time . ');
';
self::$success = '';
return $return;
}
/**
* Status
*
* @param string ...$procIds
*
* @return array
*/
public static function status(string ...$procIds) : array
{
$pending = [];
foreach( $procIds as $procId )
{
$procFile = self::getProcFile($procId);
if( is_file($procFile) )
{
$pending[$procFile] = 1; # pending.
}
}
return $pending;
}
/**
* Is finish
*
* @param string ...$procIds
*
* @return bool
*/
public static function isFinish(string ...$procIds) : bool
{
return ! in_array(1, self::status(...$procIds));
}
/**
* Dispay Report
*
* @param string $errorFile
*
* @return string
*/
public static function displayError(string $errorFile) : string
{
if( is_file($file = self::$procDir . $errorFile) && ( $fileContent = file_get_contents($file) ) )
{
$data = Json::decodeArray($fileContent);
return Buffering\Callback::do(function() use($data)
{
Exceptions::table($data['code'] ?? NULL, $data['message'], $data['file'], $data['line'], $data['trace']);
});
}
return Errors::message('File not found!');
}
/**
* Loop
*
* @param int $count
* @param int $waitSecond
* @param callable $callback
*/
public static function loop(int $count, int $waitSecond, callable $callback)
{
$i = 1;
while( true )
{
$callback($i, $waitSecond);
if( $i == $count )
{
self::close();
}
$i++;
sleep($waitSecond);
}
}
/**
* Loop Every Hour
*
* @param callable $callback
* @param bool $firstTrigger = true
*/
public static function loopEveryHour(callable $callback, bool $firstTrigger = true)
{
$check = false;
while( true )
{
if( ! $check )
{
$minute = (int) date('i');
$second = (int) date('s');
$remaining = ((60 - $minute) * 60) - $second;
}
else
{
$remaining = 3600;
}
if( $firstTrigger === true )
{
$callback();
}
sleep($remaining);
if( $firstTrigger === false )
{
$callback();
}
$check = true;
}
}
/**
* Loop Every Minute
*
* @param callable $callback
* @param bool $firstTrigger = true
*/
public static function loopEveryMinute(callable $callback, bool $firstTrigger = true)
{
$check = false;
while( true )
{
if( ! $check )
{
$second = (int) date('s');
$remaining = 60 - $second;
}
else
{
$remaining = 60;
}
if( $firstTrigger === true )
{
$callback();
}
sleep($remaining);
if( $firstTrigger === false )
{
$callback();
}
$check = true;
}
}
/**
* Is Run
*
* @param string $procId = current-process
*
* @return bool
*/
public static function isRun(string $procId = '') : bool
{
if( $pid = self::getData($procId)['status']['pid'] ?? NULL )
{
if( stripos(php_uname('s'), 'win') > -1 )
{
$output = [];
exec("tasklist /FI \"PID eq $pid\"", $output);
foreach( $output as $line)
{
if( strpos($line, (string)$pid) !== false )
{
return true;
}
}
}
else
{
exec("ps -p $pid", $output);
if( count($output) > 1 )
{
return true;
}
}
}
return false;
}
/**
* protected get proc file
*/
protected static function getProcFile(string $procId = '')
{
return $procId ? Base::prefix($procId, self::$procDir) : self::$procId;
}
/**
* protected close process
*/
protected static function closeProcess($pid)
{
return stripos(php_uname('s'), 'win') > -1 ? exec("taskkill /F /T /PID $pid") : exec("kill -9 $pid");
}
}
+31
View File
@@ -0,0 +1,31 @@
<?php namespace ZN\Console;
/**
* ZN PHP Web Framework
*
* "Simplicity is the ultimate sophistication." ~ Da Vinci
*
* @package ZN
* @license MIT [http://opensource.org/licenses/MIT]
* @author Ozan UYKUN [ozan@znframework.com]
*/
use Cache;
/**
* @command clean-cache
* @description clean-cache
*/
class CleanCache
{
/**
* Magic constructor
*
* @param
*
* @return void
*/
public function __construct()
{
new Result(Cache::clean());
}
}
+104
View File
@@ -0,0 +1,104 @@
<?php namespace ZN\Console;
/**
* ZN PHP Web Framework
*
* "Simplicity is the ultimate sophistication." ~ Da Vinci
*
* @package ZN
* @license MIT [http://opensource.org/licenses/MIT]
* @author Ozan UYKUN [ozan@znframework.com]
*/
use ZN\Singleton;
use ZN\Filesystem;
class CommandList
{
/**
* Default variables
*
* @var int
*/
protected $commandNameCount = 0, $descriptionNameCount = 0;
/**
* Magic constructor
*
* @param
*
* @return void
*/
public function __construct()
{
$numbers = [];
$getFiles = Filesystem::getFiles(__DIR__);
foreach( $getFiles as $file )
{
$class = __NAMESPACE__ . '\\' . Filesystem::removeExtension($file);
if( class_exists($class) )
{
$annotation = Singleton::class('ZN\Helpers\Reflect')->annotation($class);
if( isset($annotation->command) )
{
$numbers[strlen($annotation->command)] = strlen($annotation->description);
$commands[$annotation->command] = $annotation->description;
}
}
}
$keys = array_keys($numbers); rsort($numbers); rsort($keys);
$this->descriptionNameCount = $numbers[0];
$this->commandNameCount = $keys[0];
$line = $this->line();
$output = $line;
$output .= $this->title();
$output .= $line;
ksort($commands);
foreach( $commands as $key => $command )
{
$output .= $this->command($key, $command);
}
$output .= $line;
echo $output;
}
/**
* Protected Line
*/
protected function line()
{
return '+' . str_repeat('-', $this->commandNameCount + 2) . '+' . str_repeat('-', $this->descriptionNameCount + 2) . '+' . EOL;
}
/**
* Protected Title
*/
protected function title()
{
return '| Command' . str_repeat(' ', $this->commandNameCount - 6) . '| Description' . str_repeat(' ', $this->descriptionNameCount - 11) . ' |' . EOL;
}
/**
* Protected Command
*/
protected function command($key, $command)
{
$nameCount = $this->commandNameCount - strlen($key);
$descriptionCount = $this->descriptionNameCount - strlen($command);
$nameCount = $nameCount < 0 ? 0 : $nameCount;
$descriptionCount = $descriptionCount < 0 ? 0 : $descriptionCount;
return '| ' . $key . str_repeat(' ', $nameCount) . ' | '. $command . str_repeat(' ', $descriptionCount) . ' |' . EOL;
}
}
@@ -0,0 +1,46 @@
<?php namespace ZN\Console;
/**
* ZN PHP Web Framework
*
* "Simplicity is the ultimate sophistication." ~ Da Vinci
*
* @package ZN
* @license MIT [http://opensource.org/licenses/MIT]
* @author Ozan UYKUN [ozan@znframework.com]
*/
/**
* Default Configuration
*
* Enabled when the language file can not be accessed.
*/
class ConsoleDefaultLanguage
{
/*
|--------------------------------------------------------------------------
| Console
|--------------------------------------------------------------------------
|
| The language of the Console library.
|
*/
public $en =
[
'upgradeSuccess' => 'The upgrade was successfully completed.',
'alreadyVersion' => 'The version you are using is already up to date!',
'composerUpdate' => 'Can not upgrade! Please run the composer update command from the console.',
'success' => 'The operation completed successfully.',
'error' => 'Operation failed!'
];
public $tr =
[
'upgradeSuccess' => 'Yükseltme işlemi başarı ile tamamlandı.',
'alreadyVersion' => 'Kullandığınız sürüm zaten güncel!',
'composerUpdate' => 'Yükseltme işlemi yapılamıyor! Lütfen konsoldan composer update komutunu çalıştırarak deneyin.',
'success' => 'İşlem başarı ile tamamlandı.',
'error' => 'İşlem başarısız.'
];
}
+43
View File
@@ -0,0 +1,43 @@
<?php namespace ZN\Console;
/**
* ZN PHP Web Framework
*
* "Simplicity is the ultimate sophistication." ~ Da Vinci
*
* @package ZN
* @license MIT [http://opensource.org/licenses/MIT]
* @author Ozan UYKUN [ozan@znframework.com]
*/
use ZN\Base;
use ZN\Structure;
use ZN\Singleton;
/**
* @command run-controller
* @description run-controller controller/function/p1/p2/.../pN
*/
class Controller
{
/**
* Magic constructor
*
* @param string $command
*
* @return void
*/
public function __construct($command)
{
$datas = Structure::data($command);
$page = $datas['page'];
$function = $datas['function'];
$namespace = $datas['namespace'];
$parameters = $datas['parameters'];
$file = $datas['file'];
$class = $namespace . $page;
Base::import($file);
new Result( Singleton::class($class)->$function(...$parameters) );
}
}
@@ -0,0 +1,36 @@
<?php namespace ZN\Console;
/**
* ZN PHP Web Framework
*
* "Simplicity is the ultimate sophistication." ~ Da Vinci
*
* @package ZN
* @license MIT [http://opensource.org/licenses/MIT]
* @author Ozan UYKUN [ozan@znframework.com]
*/
use Generate;
/**
* @command create-command
* @description create-command {CommandName}
*/
class CreateCommand
{
/**
* Magic constructor
*
* @param string $command
*
* @return void
*/
public function __construct($command)
{
new Result(Generate::command($command,
[
'extends' => 'Command',
'namespace' => 'Project\Commands',
'functions' => 'run'
]));
}
}
@@ -0,0 +1,37 @@
<?php namespace ZN\Console;
/**
* ZN PHP Web Framework
*
* "Simplicity is the ultimate sophistication." ~ Da Vinci
*
* @package ZN
* @license MIT [http://opensource.org/licenses/MIT]
* @author Ozan UYKUN [ozan@znframework.com]
*/
use Generate;
use ZN\Config;
/**
* @command create-controller
* @description create-controller {ControllerName}
*/
class CreateController
{
/**
* Magic constructor
*
* @param string $command
*
* @return void
*/
public function __construct($command)
{
new Result(Generate::controller($command,
[
'extends' => 'Controller',
'namespace' => 'Project\Controllers',
'functions' => [Config::get('Routing', 'openFunction') ?: 'main']
]));
}
}
@@ -0,0 +1,34 @@
<?php namespace ZN\Console;
/**
* ZN PHP Web Framework
*
* "Simplicity is the ultimate sophistication." ~ Da Vinci
*
* @package ZN
* @license MIT [http://opensource.org/licenses/MIT]
* @author Ozan UYKUN [ozan@znframework.com]
*/
use Generate;
/**
* @command create-grand-model
* @description create-grand-model {ModelName}
*/
class CreateGrandModel
{
/**
* Magic constructor
*
* @param string $command
*
* @return void
*/
public function __construct($command)
{
new Result(Generate::model($command,
[
'extends' => 'GrandModel'
]));
}
}
@@ -0,0 +1,32 @@
<?php namespace ZN\Console;
/**
* ZN PHP Web Framework
*
* "Simplicity is the ultimate sophistication." ~ Da Vinci
*
* @package ZN
* @license MIT [http://opensource.org/licenses/MIT]
* @author Ozan UYKUN [ozan@znframework.com]
*/
use ZN\Config;
use Generate;
/**
* @command create-grand-vision
* @description create-grand-vision [database name]
*/
class CreateGrandVision
{
/**
* Magic constructor
*
* @param string $command = NULL
*
* @return void
*/
public function __construct($command = NULL)
{
new Result(Generate::grandVision($command ?: Config::get('Database', 'database')['database']));
}
}
@@ -0,0 +1,31 @@
<?php namespace ZN\Console;
/**
* ZN PHP Web Framework
*
* "Simplicity is the ultimate sophistication." ~ Da Vinci
*
* @package ZN
* @license MIT [http://opensource.org/licenses/MIT]
* @author Ozan UYKUN [ozan@znframework.com]
*/
use Migration;
/**
* @command create-migration
* @description create-migration {MigrationName}
*/
class CreateMigration
{
/**
* Magic constructor
*
* @param string $command
*
* @return void
*/
public function __construct($command, $parameters = [])
{
new Result(Migration::create($command, $parameters[0] ?? 0));
}
}
+34
View File
@@ -0,0 +1,34 @@
<?php namespace ZN\Console;
/**
* ZN PHP Web Framework
*
* "Simplicity is the ultimate sophistication." ~ Da Vinci
*
* @package ZN
* @license MIT [http://opensource.org/licenses/MIT]
* @author Ozan UYKUN [ozan@znframework.com]
*/
use Generate;
/**
* @command create-model
* @description create-model {ModelName}
*/
class CreateModel
{
/**
* Magic constructor
*
* @param string $command
*
* @return void
*/
public function __construct($command)
{
new Result(Generate::model($command,
[
'extends' => 'Model'
]));
}
}
@@ -0,0 +1,31 @@
<?php namespace ZN\Console;
/**
* ZN PHP Web Framework
*
* "Simplicity is the ultimate sophistication." ~ Da Vinci
*
* @package ZN
* @license MIT [http://opensource.org/licenses/MIT]
* @author Ozan UYKUN [ozan@znframework.com]
*/
use Generate;
/**
* @command create-project
* @description create-project {ProjectName}
*/
class CreateProject
{
/**
* Magic constructor
*
* @param string $command
*
* @return void
*/
public function __construct($command)
{
new Result(Generate::project($command));
}
}
+53
View File
@@ -0,0 +1,53 @@
<?php namespace ZN\Console;
/**
* ZN PHP Web Framework
*
* "Simplicity is the ultimate sophistication." ~ Da Vinci
*
* @package ZN
* @license MIT [http://opensource.org/licenses/MIT]
* @author Ozan UYKUN [ozan@znframework.com]
*/
use Crontab;
use ZN\IS;
/**
* @command run-cron
* @description run-cron command:method func param func param ...
*/
class Cron
{
/**
* Magic constructor
*
* @param string $command
* @param array $parameters
*
* @return void
*/
public function __construct($command, $parameters)
{
for( $index = 0, $rindex = 1; $index < count($parameters); $index += 2, $rindex += 2 )
{
$func = $parameters[$index] ?? NULL;
$prm = $parameters[$rindex] ?? NULL;
Crontab::$func($prm);
}
if( IS::url($command) ) # wget
{
$status = Crontab::wget($command);
}
elseif( strstr($command, '/') )
{
$status = Crontab::controller($command); # controller
}
else
{
$status = Crontab::command($command); # command
}
new Result($status);
}
}
+31
View File
@@ -0,0 +1,31 @@
<?php namespace ZN\Console;
/**
* ZN PHP Web Framework
*
* "Simplicity is the ultimate sophistication." ~ Da Vinci
*
* @package ZN
* @license MIT [http://opensource.org/licenses/MIT]
* @author Ozan UYKUN [ozan@znframework.com]
*/
use Crontab;
/**
* @command cron-list
* @description Cron Job List
*/
class CronList
{
/**
* Magic constructor
*
* @param void
*
* @return void
*/
public function __construct()
{
new Result(Crontab::listArray(), 'ID | JOB');
}
}
@@ -0,0 +1,31 @@
<?php namespace ZN\Console;
/**
* ZN PHP Web Framework
*
* "Simplicity is the ultimate sophistication." ~ Da Vinci
*
* @package ZN
* @license MIT [http://opensource.org/licenses/MIT]
* @author Ozan UYKUN [ozan@znframework.com]
*/
use Generate;
/**
* @command delete-command
* @description delete-command {CommandName}
*/
class DeleteCommand
{
/**
* Magic constructor
*
* @param string $command
*
* @return void
*/
public function __construct($command)
{
new Result(Generate::delete($command, 'command'));
}
}
@@ -0,0 +1,31 @@
<?php namespace ZN\Console;
/**
* ZN PHP Web Framework
*
* "Simplicity is the ultimate sophistication." ~ Da Vinci
*
* @package ZN
* @license MIT [http://opensource.org/licenses/MIT]
* @author Ozan UYKUN [ozan@znframework.com]
*/
use Generate;
/**
* @command delete-controller
* @description delete-controller {ControllerName}
*/
class DeleteController
{
/**
* Magic constructor
*
* @param string $command
*
* @return void
*/
public function __construct($command)
{
new Result(Generate::delete($command));
}
}
@@ -0,0 +1,32 @@
<?php namespace ZN\Console;
/**
* ZN PHP Web Framework
*
* "Simplicity is the ultimate sophistication." ~ Da Vinci
*
* @package ZN
* @license MIT [http://opensource.org/licenses/MIT]
* @author Ozan UYKUN [ozan@znframework.com]
*/
use ZN\Config;
use Generate;
/**
* @command delete-grand-vision
* @description delete-grand-vision [database name]
*/
class DeleteGrandVision
{
/**
* Magic constructor
*
* @param string $command
*
* @return void
*/
public function __construct($command)
{
new Result(Generate::deleteVision($command ?? '*'));
}
}
@@ -0,0 +1,31 @@
<?php namespace ZN\Console;
/**
* ZN PHP Web Framework
*
* "Simplicity is the ultimate sophistication." ~ Da Vinci
*
* @package ZN
* @license MIT [http://opensource.org/licenses/MIT]
* @author Ozan UYKUN [ozan@znframework.com]
*/
use Migration;
/**
* @command delete-migration
* @description delete-migration {MigrationName}
*/
class DeleteMigration
{
/**
* Magic constructor
*
* @param string $command
*
* @return void
*/
public function __construct($command, $parameters = [])
{
new Result(Migration::delete($command, $parameters[0] ?? 0));
}
}
@@ -0,0 +1,31 @@
<?php namespace ZN\Console;
/**
* ZN PHP Web Framework
*
* "Simplicity is the ultimate sophistication." ~ Da Vinci
*
* @package ZN
* @license MIT [http://opensource.org/licenses/MIT]
* @author Ozan UYKUN [ozan@znframework.com]
*/
use Migration;
/**
* @command delete-migration-all
* @description delete-migration-all
*/
class DeleteMigrationAll
{
/**
* Magic constructor
*
* @param string $command
*
* @return void
*/
public function __construct()
{
new Result(Migration::deleteAll());
}
}
+31
View File
@@ -0,0 +1,31 @@
<?php namespace ZN\Console;
/**
* ZN PHP Web Framework
*
* "Simplicity is the ultimate sophistication." ~ Da Vinci
*
* @package ZN
* @license MIT [http://opensource.org/licenses/MIT]
* @author Ozan UYKUN [ozan@znframework.com]
*/
use Generate;
/**
* @command delete-model
* @description delete-model {ModelName}
*/
class DeleteModel
{
/**
* Magic constructor
*
* @param string $command
*
* @return void
*/
public function __construct($command)
{
new Result(Generate::delete($command, 'model'));
}
}
@@ -0,0 +1,31 @@
<?php namespace ZN\Console;
/**
* ZN PHP Web Framework
*
* "Simplicity is the ultimate sophistication." ~ Da Vinci
*
* @package ZN
* @license MIT [http://opensource.org/licenses/MIT]
* @author Ozan UYKUN [ozan@znframework.com]
*/
use ZN\Filesystem;
/**
* @command delete-project
* @description delete-project {ProjectName}
*/
class DeleteProject
{
/**
* Magic constructor
*
* @param string $command
*
* @return void
*/
public function __construct($command)
{
new Result(Filesystem\Forge::deleteFolder(PROJECTS_DIR . $command));
}
}
@@ -0,0 +1,33 @@
<?php namespace ZN\Console;
/**
* ZN PHP Web Framework
*
* "Simplicity is the ultimate sophistication." ~ Da Vinci
*
* @package ZN
* @license MIT [http://opensource.org/licenses/MIT]
* @author Ozan UYKUN [ozan@znframework.com]
*/
use Migration;
/**
* @command down-migration
* @description down-migration {MigrationName}
*/
class DownMigration
{
/**
* Magic constructor
*
* @param string $command
*
* @return void
*/
public function __construct($command, $parameters)
{
$migration = 'Migrate' . $command;
new Result($migration::down($command, ...$parameters));
}
}
@@ -0,0 +1,31 @@
<?php namespace ZN\Console;
/**
* ZN PHP Web Framework
*
* "Simplicity is the ultimate sophistication." ~ Da Vinci
*
* @package ZN
* @license MIT [http://opensource.org/licenses/MIT]
* @author Ozan UYKUN [ozan@znframework.com]
*/
use ZN\Restoration;
/**
* @command end-restoration
* @description end-restoration {ProjectName}
*/
class EndRestoration
{
/**
* Magic constructor
*
* @param string $command
*
* @return void
*/
public function __construct($command)
{
new Result(Restoration::end($command));
}
}
@@ -0,0 +1,31 @@
<?php namespace ZN\Console;
/**
* ZN PHP Web Framework
*
* "Simplicity is the ultimate sophistication." ~ Da Vinci
*
* @package ZN
* @license MIT [http://opensource.org/licenses/MIT]
* @author Ozan UYKUN [ozan@znframework.com]
*/
use ZN\Restoration;
/**
* @command end-restoration-delete
* @description end-restoration-delete {ProjectName}
*/
class EndRestorationDelete
{
/**
* Magic constructor
*
* @param string $command
*
* @return void
*/
public function __construct($command)
{
new Result(Restoration::endDelete($command));
}
}
+54
View File
@@ -0,0 +1,54 @@
<?php namespace ZN\Console;
/**
* ZN PHP Web Framework
*
* "Simplicity is the ultimate sophistication." ~ Da Vinci
*
* @package ZN
* @license MIT [http://opensource.org/licenses/MIT]
* @author Ozan UYKUN [ozan@znframework.com]
*/
/**
* @command environment
* @description environment key value
*
* @codeCoverageIgnore
*/
class Environment
{
/**
* Env
*
* @var string
*/
const env = 'env';
/**
* Magic constructor
*
* @param string $command
* @param array $parameters
*
* @return void
*/
public function __construct($command, $parameters)
{
$data = json_decode(file_get_contents(self::env) ?: '', true) ?: [];
$data[$command] = $parameters[0] ?? '';
file_put_contents(self::env, json_encode($data));
}
/**
* Export environment variables
*
*/
public static function export($key)
{
$data = json_decode(file_get_contents(self::env) ?: '', true) ?: [];
return $data[$key] ?? '';
}
}
@@ -0,0 +1,52 @@
<?php namespace ZN\Console;
/**
* ZN PHP Web Framework
*
* "Simplicity is the ultimate sophistication." ~ Da Vinci
*
* @package ZN
* @license MIT [http://opensource.org/licenses/MIT]
* @author Ozan UYKUN [ozan@znframework.com]
*/
use ZN\Filesystem;
/**
* @command export-docker-container
* @description export-docker-container {version}
*
* @codeCoverageIgnore
*/
class ExportDockerContainer
{
/**
* Magic constructor
*
* @param string $command
*
* @return void
*/
public function __construct($command)
{
$directory = 'software-drivers/Docker/' . $command . '/';
if( ! is_dir($directory) )
{
new Result($directory . ' not found!'); return;
}
$dockerFile = file_get_contents($directory . 'Dockerfile');
$dockerComposeFile = file_get_contents($directory . 'docker-compose.yml');
if( file_put_contents('Dockerfile', $dockerFile) && file_put_contents('docker-compose.yml', $dockerComposeFile) )
{
Filesystem::deleteFolder('software-drivers');
new Result(true);
}
else
{
new Result(false);
}
}
}
@@ -0,0 +1,37 @@
<?php namespace ZN\Console;
/**
* ZN PHP Web Framework
*
* "Simplicity is the ultimate sophistication." ~ Da Vinci
*
* @package ZN
* @license MIT [http://opensource.org/licenses/MIT]
* @author Ozan UYKUN [ozan@znframework.com]
*/
use ZN\Butcher;
/**
* @command extract-butcher
* @description extract-butcher [all|{name}] [title|lower|slug|normal|{name}]
*/
class ExtractButcher
{
/**
* Magic constructor
*
* @param string $command
* @param array $parameters
*
* @return void
*/
public function __construct($command, $parameters)
{
new Result((new Butcher)->extract
(
$command ?? 'all',
$parameters[0] ?? 'title',
$parameters[1] ?? 'project'
));
}
}
@@ -0,0 +1,37 @@
<?php namespace ZN\Console;
/**
* ZN PHP Web Framework
*
* "Simplicity is the ultimate sophistication." ~ Da Vinci
*
* @package ZN
* @license MIT [http://opensource.org/licenses/MIT]
* @author Ozan UYKUN [ozan@znframework.com]
*/
use ZN\Butcher;
/**
* @command extract-butcher-delete
* @description extract-butcher-delete [all|{name}] [title|lower|slug|normal|{name}]
*/
class ExtractButcherDelete
{
/**
* Magic constructor
*
* @param string $command
* @param array $parameters
*
* @return void
*/
public function __construct($command, $parameters)
{
new Result((new Butcher)->extractDelete
(
$command ?? 'all',
$parameters[0] ?? 'title',
$parameters[1] ?? 'project'
));
}
}
@@ -0,0 +1,37 @@
<?php namespace ZN\Console;
/**
* ZN PHP Web Framework
*
* "Simplicity is the ultimate sophistication." ~ Da Vinci
*
* @package ZN
* @license MIT [http://opensource.org/licenses/MIT]
* @author Ozan UYKUN [ozan@znframework.com]
*/
use ZN\Butcher;
/**
* @command extract-butcher-force
* @description extract-butcher-force [all|{name}] [title|lower|slug|normal|{name}]
*/
class ExtractButcherForce
{
/**
* Magic constructor
*
* @param string $command
* @param array $parameters
*
* @return void
*/
public function __construct($command, $parameters)
{
new Result((new Butcher)->extractForce
(
$command ?? 'all',
$parameters[0] ?? 'title',
$parameters[1] ?? 'project'
));
}
}
@@ -0,0 +1,31 @@
<?php namespace ZN\Console;
/**
* ZN PHP Web Framework
*
* "Simplicity is the ultimate sophistication." ~ Da Vinci
*
* @package ZN
* @license MIT [http://opensource.org/licenses/MIT]
* @author Ozan UYKUN [ozan@znframework.com]
*/
use Generate;
/**
* @command generate-databases
* @description generate-databases
*/
class GenerateDatabases
{
/**
* Magic constructor
*
* @param void
*
* @return void
*/
public function __construct()
{
new Result(Generate::databases());
}
}
@@ -0,0 +1,47 @@
<?php namespace ZN\Console;
/**
* ZN PHP Web Framework
*
* "Simplicity is the ultimate sophistication." ~ Da Vinci
*
* @package ZN
* @license MIT [http://opensource.org/licenses/MIT]
* @author Ozan UYKUN [ozan@znframework.com]
*/
use ZN\Base;
/**
* @command generate-project-key
* @description generate-project-key [addional]
*/
class GenerateProjectKey
{
/**
* Magic constructor
*
* @param string $command
*
* @return void
*/
public function __construct($command)
{
$contents = file_get_contents($file = CONFIG_DIR . 'Project.php');
$replaceContents = preg_replace_callback('/(?<key>\'key\'\s*=>\s*)(?<data>.*?),\s*$/m', function($data)
{
return $data['key'] . Base::presuffix(hash('ripemd320', uniqid($command ?? '')), '\'') . ',' . PHP_EOL;
}, $contents);
$return = false;
if( $contents !== $replaceContents )
{
$return = (bool) file_put_contents($file, $replaceContents);
}
$message = $return === true ? 'Project key was created with success.' : 'Project key could not be created!';
new Result($message);
}
}
+52
View File
@@ -0,0 +1,52 @@
<?php namespace ZN\Console;
/**
* ZN PHP Web Framework
*
* "Simplicity is the ultimate sophistication." ~ Da Vinci
*
* @package ZN
* @license MIT [http://opensource.org/licenses/MIT]
* @author Ozan UYKUN [ozan@znframework.com]
*/
use ZN\Singleton;
/**
* @command run-command / run-external-command
* @description run-command command:function p1 p2 ...pN
*/
class Library
{
/**
* Magic constructor
*
* @param string $command
* @param array $parameters
* @param string $namespace = NULL
*
* @return void
*/
public function __construct($command, $parameters, $namespace = NULL)
{
$this->classMethod($class, $method, $command);
$className = $namespace . $class;
new Result( Singleton::class($className)->$method(...$parameters) );
}
/**
* protected class method
*
* @param string &$class
* @param string &$method
*
* @return void
*/
protected function classMethod(&$class = NULL, &$method = NULL, $command = NULL)
{
$commandEx = explode(':', (string) $command);
$class = $commandEx[0];
$method = $commandEx[1] ?? NULL;
}
}
+30
View File
@@ -0,0 +1,30 @@
<?php namespace ZN\Console;
/**
* ZN PHP Web Framework
*
* "Simplicity is the ultimate sophistication." ~ Da Vinci
*
* @package ZN
* @license MIT [http://opensource.org/licenses/MIT]
* @author Ozan UYKUN [ozan@znframework.com]
*/
/**
* @command run-function
* @description run-function function p1 p2 ... pN
*/
class Method
{
/**
* Magic constructor
*
* @param string $method
* @param string $parameters
*
* @return void
*/
public function __construct($method, $parameters)
{
new Result($method(...$parameters));
}
}
@@ -0,0 +1,31 @@
<?php namespace ZN\Console;
/**
* ZN PHP Web Framework
*
* "Simplicity is the ultimate sophistication." ~ Da Vinci
*
* @package ZN
* @license MIT [http://opensource.org/licenses/MIT]
* @author Ozan UYKUN [ozan@znframework.com]
*/
use Migration;
/**
* @command multidown-migration
* @description multidown-migration {MigrationName}
*/
class MultidownMigration
{
/**
* Magic constructor
*
* @param string $command
*
* @return void
*/
public function __construct($command, $parameters)
{
new Result(Migration::downAll($command, ...$parameters));
}
}
@@ -0,0 +1,31 @@
<?php namespace ZN\Console;
/**
* ZN PHP Web Framework
*
* "Simplicity is the ultimate sophistication." ~ Da Vinci
*
* @package ZN
* @license MIT [http://opensource.org/licenses/MIT]
* @author Ozan UYKUN [ozan@znframework.com]
*/
use Migration;
/**
* @command multiup-migration
* @description multiup-migration {name1, name2 ...}
*/
class MultiupMigration
{
/**
* Magic constructor
*
* @param string $command
*
* @return void
*/
public function __construct($command, $parameters)
{
new Result(Migration::upAll($command, ...$parameters));
}
}
+31
View File
@@ -0,0 +1,31 @@
<?php namespace ZN\Console;
/**
* ZN PHP Web Framework
*
* "Simplicity is the ultimate sophistication." ~ Da Vinci
*
* @package ZN
* @license MIT [http://opensource.org/licenses/MIT]
* @author Ozan UYKUN [ozan@znframework.com]
*/
use Crontab;
/**
* @command remove-cron
* @description remove-cron {cronID}
*/
class RemoveCron
{
/**
* Magic constructor
*
* @param array $parameters
*
* @return void
*/
public function __construct($parameters)
{
new Result(Crontab::remove($parameters ?? NULL));
}
}
+162
View File
@@ -0,0 +1,162 @@
<?php namespace ZN\Console;
/**
* ZN PHP Web Framework
*
* "Simplicity is the ultimate sophistication." ~ Da Vinci
*
* @package ZN
* @license MIT [http://opensource.org/licenses/MIT]
* @author Ozan UYKUN [ozan@znframework.com]
*/
use ZN\Lang;
use ZN\Buffering;
class Result
{
protected $title = 'RESULT';
protected $return;
protected $print;
/**
* Magic constructor
*
* @param mixed $result
*
* @return void
*/
public function __construct($result, $title = NULL)
{
if( $title !== NULL )
{
$this->title = $title;
}
$this->return = Buffering\Callback::do(function() use($result)
{
$success = Lang::default('ZN\Console\ConsoleDefaultLanguage')::select('Success', 'success');
$error = Lang::default('ZN\Console\ConsoleDefaultLanguage')::select('Error', 'error');
$nodata = 'No Data';
if( $result === true || $result === NULL )
{
echo $success;
}
elseif( $result === false )
{
echo $error;
}
else
{
if( is_array($result) )
{
if( ! empty($result) )
{
$this->print = $result;
}
else
{
echo $nodata;
}
}
else
{
if( ! empty($result) )
{
echo $result;
}
else
{
echo $nodata;
}
}
}
});
if( isset($this->print) )
{
$this->outputMultipleResult();
}
else
{
$this->outputSingleResult();
}
}
/**
* Protected Line
*/
protected function line()
{
return '+' . str_repeat
(
'-',
(($returnLength = strlen($this->return)) < ($titleLength = (strlen($this->title)))
? $titleLength
: $returnLength
)) . '--+' . EOL;
}
/**
* Protected Title
*/
protected function title()
{
return '| '.$this->title.' ' . str_repeat
(
' ',
($returnLength = strlen($this->return)) >= ($titleLength = strlen($this->title))
? $returnLength - $titleLength
: 0
) . '|' . EOL;
}
/**
* Protected Content
*/
protected function content()
{
return '| ' . $this->return . str_repeat
(
' ',
(($returnLength = strlen($this->return)) < ($titleLength = strlen($this->title))
? $titleLength - $returnLength + 1
: 1
)) . '|'.EOL;
}
/**
* Protected output single result
*/
protected function outputSingleResult()
{
echo EOL;
echo $this->line();
echo $this->title();
echo $this->line();
echo $this->content();
echo $this->line();
}
/**
* Protected output multiple result
*/
protected function outputMultipleResult()
{
$this->return = $max = max($this->print) . ' ';
echo EOL;
echo $this->line();
echo $this->title();
echo $this->line();
foreach( $this->print as $key => $ret )
{
$diff = strlen($max) - strlen($return = $key . ' | ' . $ret);
$this->return = $return . str_repeat(' ', $diff);
echo $this->content();
echo $this->line();
}
}
}
+130
View File
@@ -0,0 +1,130 @@
<?php namespace ZN\Console;
/**
* ZN PHP Web Framework
*
* "Simplicity is the ultimate sophistication." ~ Da Vinci
*
* @package ZN
* @license MIT [http://opensource.org/licenses/MIT]
* @author Ozan UYKUN [ozan@znframework.com]
*/
use ZN\Helper;
/**
* @codeCoverageIgnore
*/
class Run
{
/**
* Default Project Name
*
* @var string
*/
protected static $project = DEFAULT_PROJECT;
/**
* Keep command
*
* @var string
*/
protected static $command;
/**
* Keep parameters
*
* @var array
*/
protected static $parameters;
/**
* Run commands
*
* @param array $commands
*
* @return void
*/
public function __construct($commands)
{
Helper::report('TerminalCommands', implode(' ', $commands), 'TerminalCommands');
array_shift($commands);
if( ($commands[0] ?? NULL) !== 'project-name' )
{
array_unshift($commands, DEFAULT_PROJECT);
array_unshift($commands, 'project-name');
}
$realCommands = implode(' ', self::arrayRemoveFirst($commands, 2));
self::$project = $commands[1] ?? DEFAULT_PROJECT;
$command = $commands[2] ?? NULL;
self::$command = $commands[3] ?? NULL;
if( $command === NULL )
{
new CommandList; exit;
}
self::$parameters = self::arrayRemoveFirst($commands, 4);
switch( $command )
{
case 'run-uri' :
case 'run-controller' : new Controller(self::$command); break;
case 'run-model' :
case 'run-class' : new Library(self::$command, self::$parameters); break;
case 'run-cron' : new Cron(self::$command, self::$parameters); break;
case 'run-command' : new Library(self::$command, self::$parameters, PROJECT_COMMANDS_NAMESPACE); break;
case 'run-external-command' : new Library(self::$command, self::$parameters, EXTERNAL_COMMANDS_NAMESPACE); break;
case 'run-function' : new Method(self::$command, self::$parameters); break;
default :
# 5.3.5[added]
if( strstr($realCommands, ':') )
{
new ShortCommand($realCommands);
}
# 5.7.2
elseif( class_exists($class = ('ZN\Console\\'. self::titleCase($command))) )
{
new $class(self::$command, self::$parameters);
}
else
{
new TerminalCommand($realCommands);
}
}
}
/**
* Protected title case
*/
protected static function titleCase($command)
{
$words = explode('-', $command ?? '');
$words = array_map(function($data){ return mb_convert_case($data, MB_CASE_TITLE);}, $words);
return implode('', $words);
}
/**
* Array Remove First
*
* @param array & $array
* @param int $count = 1
*
* @return array
*
*/
protected static function arrayRemoveFirst(array $array, int $count = 1) : array
{
for( $i = 0; $i < $count; $i++ )
{
array_shift($array);
}
return $array;
}
}
+31
View File
@@ -0,0 +1,31 @@
<?php namespace ZN\Console;
/**
* ZN PHP Web Framework
*
* "Simplicity is the ultimate sophistication." ~ Da Vinci
*
* @package ZN
* @license MIT [http://opensource.org/licenses/MIT]
* @author Ozan UYKUN [ozan@znframework.com]
*/
use ZN\Butcher;
/**
* @command run-butcher
* @description run-butcher [theme-directory-name] [project|external]
*/
class RunButcher
{
/**
* Magic constructor
*
* @param string $command
*
* @return void
*/
public function __construct($command, $parameters)
{
new Result((new Butcher)->run($command ?? 'Default', $parameters[0] ?? 'project'));
}
}
@@ -0,0 +1,31 @@
<?php namespace ZN\Console;
/**
* ZN PHP Web Framework
*
* "Simplicity is the ultimate sophistication." ~ Da Vinci
*
* @package ZN
* @license MIT [http://opensource.org/licenses/MIT]
* @author Ozan UYKUN [ozan@znframework.com]
*/
use ZN\Butcher;
/**
* @command run-butcher-delete
* @description run-butcher-delete [theme-directory-name] [project|external]
*/
class RunButcherDelete
{
/**
* Magic constructor
*
* @param string $command
*
* @return void
*/
public function __construct($command, $parameters)
{
new Result((new Butcher)->runDelete($command ?? 'Default', $parameters[0] ?? 'project'));
}
}
+53
View File
@@ -0,0 +1,53 @@
<?php namespace ZN\Console;
/**
* ZN PHP Web Framework
*
* "Simplicity is the ultimate sophistication." ~ Da Vinci
*
* @package ZN
* @license MIT [http://opensource.org/licenses/MIT]
* @author Ozan UYKUN [ozan@znframework.com]
*/
use ZN\Singleton;
/**
* @command command:method
* @description Run short command
*/
class ShortCommand
{
/**
* Magic constructor
*
* @param string $command
*
* @return void
*/
public function __construct($command)
{
$commandEx = explode(':', $command ?? '');
$classEx = explode('\\', $commandEx[0]);
$funcparamEx = explode(' ', $commandEx[1] ?? '');
$function = $funcparamEx[0];
$parameters = [];
if( $funcparamEx[1] ?? NULL )
{
array_shift($funcparamEx);
$parameters = $funcparamEx;
}
if( strtolower($classEx[0]) === 'external' )
{
$class = EXTERNAL_COMMANDS_NAMESPACE . $classEx[1]; // @codeCoverageIgnore
}
else
{
$class = PROJECT_COMMANDS_NAMESPACE . $classEx[0];
}
new Result( Singleton::class($class)->$function(...$parameters) );
}
}
@@ -0,0 +1,36 @@
<?php namespace ZN\Console;
/**
* ZN PHP Web Framework
*
* "Simplicity is the ultimate sophistication." ~ Da Vinci
*
* @package ZN
* @license MIT [http://opensource.org/licenses/MIT]
* @author Ozan UYKUN [ozan@znframework.com]
*/
use ZN\Restoration;
/**
* @command start-restoration
* @description start-restoration {ProjectName} [full, standart or [directories]]
*/
class StartRestoration
{
/**
* Magic constructor
*
* @param string $command
* @param string $parameters
*
* @return void
*/
public function __construct($command, $parameters = [])
{
new Result(Restoration::start
(
$command,
($parameters[0] ?? NULL) === 'full' ? 'full' : $parameters
));
}
}
@@ -0,0 +1,27 @@
<?php namespace ZN\Console;
/**
* ZN PHP Web Framework
*
* "Simplicity is the ultimate sophistication." ~ Da Vinci
*
* @package ZN
* @license MIT [http://opensource.org/licenses/MIT]
* @author Ozan UYKUN [ozan@znframework.com]
*/
class TerminalCommand
{
/**
* Magic constructor
*
* @param string $realCommands
*
* @return void
*/
public function __construct($realCommands)
{
exec($realCommands, $response);
new Result($response[0] ?? false);
}
}
+33
View File
@@ -0,0 +1,33 @@
<?php namespace ZN\Console;
/**
* ZN PHP Web Framework
*
* "Simplicity is the ultimate sophistication." ~ Da Vinci
*
* @package ZN
* @license MIT [http://opensource.org/licenses/MIT]
* @author Ozan UYKUN [ozan@znframework.com]
*/
use ZN\ZN;
/**
* @command undo-upgrade
* @description undo-upgrade [last|version-number]
*/
class UndoUpgrade
{
protected static $lang;
/**
* Magic constructor
*
* @param void
*
* @return void
*/
public function __construct($command)
{
new Result(ZN::undoUpgrade($command ?? 'last'));
}
}
+33
View File
@@ -0,0 +1,33 @@
<?php namespace ZN\Console;
/**
* ZN PHP Web Framework
*
* "Simplicity is the ultimate sophistication." ~ Da Vinci
*
* @package ZN
* @license MIT [http://opensource.org/licenses/MIT]
* @author Ozan UYKUN [ozan@znframework.com]
*/
use Migration;
/**
* @command up-migration
* @description up-migration {MigrationName}
*/
class UpMigration
{
/**
* Magic constructor
*
* @param string $command
*
* @return void
*/
public function __construct($command, $parameters)
{
$migration = 'Migrate' . $command;
new Result($migration::up($command, ...$parameters));
}
}
+90
View File
@@ -0,0 +1,90 @@
<?php namespace ZN\Console;
/**
* ZN PHP Web Framework
*
* "Simplicity is the ultimate sophistication." ~ Da Vinci
*
* @package ZN
* @license MIT [http://opensource.org/licenses/MIT]
* @author Ozan UYKUN [ozan@znframework.com]
*/
use File;
use Restful;
use ZN\ZN;
use ZN\Lang;
/**
* @command upgrade
* @description upgrade
*
* @codeCoverageIgnore
*/
class Upgrade
{
protected static $lang;
/**
* Magic constructor
*
* @param void
*
* @return void
*/
public function __construct()
{
self::$lang = Lang::default('ZN\Console\ConsoleDefaultlanguage')::select('Console');
if( ZN::$projectType === 'FE' )
{
$return = self::fe();
}
else
{
$return = self::upgrade();
}
new Result($return);
}
/**
* Protected upgrade FE
*/
protected static function fe()
{
if( ! empty(ZN::upgrade()) )
{
$status = self::$lang['upgradeSuccess'];
}
else
{
$status = self::$lang['alreadyVersion'];
if( $upgradeError = ZN::upgradeError() )
{
$status = $upgradeError;
}
}
return $status;
}
/**
* Proteted upgrade EIP
*/
protected static function upgrade()
{
$open = popen('composer update 2>&1', 'r');
$result = fread($open, 2048);
pclose($open);
if( empty($result) )
{
return self::$lang['composerUpdate'];
}
return self::$lang['upgradeSuccess'];
}
}
+49
View File
@@ -0,0 +1,49 @@
#!/usr/bin/env php
<?php
/*
|--------------------------------------------------------------------------
| Console Usage
|--------------------------------------------------------------------------
|
| It keeps track of whether processes are running through the console.
|
*/
define('CONSOLE_ENABLED', true);
/*
|--------------------------------------------------------------------------
| Project Name
|--------------------------------------------------------------------------
|
| The project to be processed is selected.
|
*/
if( ($argv[1] ?? NULL) === 'project-name' )
{
define('CONSOLE_PROJECT_NAME', $argv[2]);
}
/*
|--------------------------------------------------------------------------
| Require zeroneed.php
|--------------------------------------------------------------------------
|
| The file containing the system and basic structures is included.
|
*/
require_once __DIR__ . '/zeroneed.php';
/*
|--------------------------------------------------------------------------
| Run Console
|--------------------------------------------------------------------------
|
| It was created in order to use the existing frameworks of the ZN
| when you need to send commands to the PHP client via the console.
|
*/
new ZN\Console\Run($argv);