Commit 9ea41529 authored by Sigitas Zelenkovas's avatar Sigitas Zelenkovas Committed by Sigitas Zelenkovas

Initial import

parents
Pipeline #7 failed with stages
* text=auto
*.php text eol=lf
*.twig text eol=lf
/.idea
/vendor
/report
/composer.lock
# Deployments:
On selected server it is enough to run single script: `deploy`, which is
located in root project directory.
### Automatic
Run following command in root project directory:
```text
./deploy
```
### Or if required to do manually, here are following steps:
1. `git pull origin master` - pull new code
2. `git submodule update` - update all dependencies, especialy main framework
3. `php composer.phar dump-autoload` - generate new class tree
4. `php commander.php migrate:` - run database migrations
### Servers
```text
Todo...
```
---
# Unit tests
This project contains unit tests which can be run with following command:
```text
php phpunit.phar
```
### There are 2 types of tests which should be ran:
1. **With process isolation** - each test runs in seperate php process
ensuring no prevous tests will affect currently running test
2. **Without process isolation** - All process run in one go. Using this method
tests finish a lot faster. This also provides good indication if prevous tests
do not affect other tests.
### Command variantions
```text
php phpunit.phar
php phpunit.phar --process-isolation
```
<?php
return [
"DebugMode" => false,
"CommandDirectory" => __DIR__."/commands/",
"MigrationDirectory" => __DIR__."/migrations/",
"TemplateDirectory" => __DIR__."/templates/",
"ControllerDirectory" => __DIR__."/controllers/",
"MapDirectory" => __DIR__."/maps/",
"ObjectDirectory" => __DIR__."/object/",
"DataDirectory" => realpath(__DIR__."/../data")."/",
"DefaultController" => "Index",
"DefaultAction" => "Index",
"UserAgentFilter" => "/^.*$/",
"VendorAutoLoader" => realpath(__DIR__."/../vendor")."/autoload.php",
"TwigCache" => realpath(__DIR__."/../data/twig")."/",
"TokenName" => "HTTP_X_TOKEN",
"RealIPHeader" => "REMOTE_ADDR",
"CacheModule" => "Array",
"CacheHeaders" => [],
"Cache" =>
[
"MemcacheCacheModule" =>
[
//ip port weight
["127.0.0.1", 11211, 100]
]
],
"Connections" =>
[
"_default" => "apisqlite",
"api" =>
[
"Type" => "mysql",
"MysqlHost" => "localhost",
"MysqlPort" => 3306,
"MysqlUser" => null,
"MysqlPass" => null,
"MysqlDb" => null
],
"apisqlite" =>
[
"Type" => "sqlite",
"Memory" => true
]
]
];
<?php
namespace App\Controllers;
class IndexController extends Controller
{
public function GetIndex()
{
return $this->Render(["Hello" => "world"]);
}
}
<?php
use Core\Config;
use Core\Cache\Cache;
use Core\Router\Router;
error_reporting(E_ALL);
require_once(__DIR__."/../framework/core/Config.php");
Config::Init(require_once(__DIR__."/config.php"));
require_once(Config::VendorAutoLoader());
Cache::Init(Config::CacheModule());
Router::SetControllerDirectory(Config::ControllerDirectory());
Router::SetDefaultController(Config::DefaultController(), Config::DefaultAction());
Router::KnownVersions(
[
]);
Router::NoActionExceptions(
[
]);
Router::WhiteList(
[
"/^.*$/",
]);
if(php_sapi_name() !== "cli")
Router::Route($_SERVER['REQUEST_URI']);
<?php
use App\Maps\ApiMap;
use App\Objects\User;
use Core\Config;
use Core\Cron\Cron;
use Core\Cron\CronEntry;
use Core\Cron\CronSchedule;
use Core\Database\Database;
use Core\Database\Query\Query;
Cron::Register((new CronEntry(new CronSchedule("0 * * * *"), function($cron)
{
}))->Description("Print hello world every minute"), basename(__FILE__));
<?php
namespace App\Maps;
use Core\Database\DatabaseMap;
use PDO;
/**
* Class ApiMap
* @package App\Maps
*
*/
class ApiMap extends DatabaseMap
{
public function __call($name, $arguments)
{
return parent::call($name, $arguments, $this, __CLASS__);
}
public static function __callStatic($name, $arguments)
{
return call_user_func_array([new self(), $name], $arguments);
}
}
<?php
namespace App\Objects;
use App\Maps\ApiMap;
use Core\Controller;
/**
* Class User
* @package App\Objects
*
* @property int $id
*/
class User
{
}
#!/usr/bin/env php
<?php
use Core\Command\Commander;
require_once("app/core.php");
Commander::Execute($argv);
{
"name": "vendor_name/package_name",
"description": "description_text",
"minimum-stability": "stable",
"authors": [
{
"name": "author's name",
"email": "email@example.com"
}
],
"require": {
"twig/twig": "v1.15.1",
"hexide-api/core": "dev-master",
"hexide-api/installer": "dev-master"
},
"repositories": [
{
"type": "git",
"url": "ssh://git@git.hexide.com:23/hexide-api/core.git"
},
{
"type": "git",
"url": "ssh://git@git.hexide.com:23/hexide-api/installer.git"
}
],
"autoload": {
"classmap": [
"framework/",
"app/controllers/",
"app/maps/",
"app/object/"
]
}
}
File added
#!/usr/bin/env php
<?php
use Core\Cron\Cron;
use Core\Cron\CronEntry;
use Core\Cron\CronSchedule;
use Core\IO\Directory;
require_once("app/core.php");
$crons = [];
$lists = Directory::GetDirectoryContents("app/cron");
foreach($lists as $entry)
{
require_once("app/cron/{$entry}");
}
Cron::Trigger(isset($argv) && isset($argv[1]) ? $argv[1] : null);
#!/bin/bash
echo "------------------------------------------------"
echo "Downloading Composer... "
if [ ! -f phpunit.phar ]; then wget https://phar.phpunit.de/phpunit.phar -q -O phpunit.phar; fi
echo "------------------------------------------------"
echo
echo "------------------------------------------------"
echo "Pulling from git..."
git pull origin
echo "------------------------------------------------"
echo
echo "------------------------------------------------"
echo "Updating submodules..."
git submodule update
echo "------------------------------------------------"
echo
echo "------------------------------------------------"
echo "Updating composer..."
php composer.phar self-update
echo "------------------------------------------------"
echo
echo "------------------------------------------------"
echo "Dumping auto-load..."
php composer.phar dump-autoload
echo "------------------------------------------------"
echo
echo "------------------------------------------------"
echo "Running all new migrations"
php commander.php migrate:
echo "------------------------------------------------"
echo
echo "All done!"
framework @ 7ee1dbf2
Subproject commit 7ee1dbf2bf4edf2e702d3a4aa34428a8773be991
This diff is collapsed.
<?xml version="1.0" encoding="UTF-8"?>
<phpunit backupGlobals="false"
backupStaticAttributes="false"
bootstrap="framework/tests/bootstrap.php"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
syntaxCheck="true"
strict="true"
verbose="true"
>
<testsuites>
<testsuite name="Framework test suite">
<directory>./framework/tests</directory>
</testsuite>
<testsuite name="Application Test Suite">
<directory>./core/dynamic/tests</directory>
</testsuite>
</testsuites>
<logging>
<log type="coverage-text" target="php://stdout" showUncoveredFiles="true" />
<log type="coverage-html" target="report/" charset="UTF-8" highlight="true" />
</logging>
<filter>
<whitelist addUncoveredFilesFromWhitelist="true">
<directory>core/class</directory>
<directory>core/dynamic/controllers</directory>
<directory>core/dynamic/cron</directory>
<directory>core/dynamic/maps</directory>
<directory>core/dynamic/object</directory>
</whitelist>
<blacklist>
<directory>tests</directory>
<directory>core/dynamic/tests</directory>
</blacklist>
</filter>
</phpunit>
<?php
header("Connection: close");
require_once("../app/core.php");
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment