Skip to content

Commit

Permalink
move model/view/controller under src/ and install php-cs-fixer style …
Browse files Browse the repository at this point in the history
…checker
  • Loading branch information
osma committed Apr 18, 2023
1 parent 83087ae commit cc8d10e
Show file tree
Hide file tree
Showing 76 changed files with 77 additions and 231 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ jobs:
php_version: ${{ matrix.php_version }}
php_extensions: gettext intl xsl pcov

- name: Check PHP code style
run: ./vendor/bin/php-cs-fixer --diff --dry-run

- name: Run PHPUnit tests
uses: php-actions/phpunit@v3
env:
Expand Down
6 changes: 3 additions & 3 deletions .htaccess
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@ Options +FollowSymlinks -MultiViews -Indexes
RewriteEngine on

RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^entity$ entity.php [L]
RewriteRule ^entity$ src/entity.php [L]

RewriteRule ^rest/v1/swagger.json$ swagger.json [L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^rest/v1/(.*)$ rest.php/$1 [L]
RewriteRule ^rest/v1/(.*)$ src/rest.php/$1 [L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond $0 !^resource/
RewriteRule ^(.*)$ index.php/$1 [L]
RewriteRule ^(.*)$ src/index.php/$1 [L]

RewriteCond $0 ^favicon.ico$
RewriteCond custom-favicon.ico -F
Expand Down
5 changes: 3 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,10 @@
"require-dev": {
"phpunit/phpunit": "9.5.*",
"symfony/dom-crawler": "5.4.*",
"mockery/mockery": "1.5.1"
"mockery/mockery": "1.5.1",
"friendsofphp/php-cs-fixer": "3.16.*"
},
"autoload": {
"classmap": ["controller/", "model/", "model/sparql/"]
"classmap": ["src/controller/", "src/model/", "src/model/sparql/"]
}
}
153 changes: 0 additions & 153 deletions migrate-config.php

This file was deleted.

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public function __construct($model)
}

// specify where to look for templates and cache
$loader = new Twig_Loader_Filesystem('view');
$loader = new Twig_Loader_Filesystem('src/view');
// initialize Twig environment
$this->twig = new Twig_Environment($loader, array('cache' => $tmpDir,'auto_reload' => true));
$this->twig->addExtension(new Twig_Extensions_Extension_I18n());
Expand Down
2 changes: 1 addition & 1 deletion entity.php → src/entity.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/**
* Includes the side wide settings.
*/
require_once 'vendor/autoload.php';
require_once '../vendor/autoload.php';

header("Access-Control-Allow-Origin: *"); // enable CORS

Expand Down
4 changes: 2 additions & 2 deletions index.php → src/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
* Use Composer autoloader to automatically load library classes.
*/
try {
if (!file_exists('./vendor/autoload.php')) {
if (!file_exists('../vendor/autoload.php')) {
throw new Exception('Dependencies managed by Composer missing. Please run "php composer.phar install".');
}
require_once 'vendor/autoload.php';
require_once '../vendor/autoload.php';
} catch (Exception $e) {
echo "Error: " . $e->getMessage();
return;
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions model/GlobalConfig.php → src/model/GlobalConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ class GlobalConfig extends BaseConfig {
*/
private $configModifiedTime = null;

public function __construct($config_name='/../config.ttl')
public function __construct($config_name='../../config.ttl')
{
$this->cache = new Cache();
try {
$this->filePath = realpath( dirname(__FILE__) . $config_name );
$this->filePath = realpath( dirname(__FILE__) . "/" . $config_name );
if (!file_exists($this->filePath)) {
throw new Exception('config.ttl file is missing, please provide one.');
}
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion rest.php → src/rest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/**
* Includes the side wide settings.
*/
require_once 'vendor/autoload.php';
require_once '../vendor/autoload.php';

header("Access-Control-Allow-Origin: *"); // enable CORS for the whole REST API

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion tests/ConceptMappingPropertyValueTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ protected function setUp() : void
bind_textdomain_codeset('skosmos', 'UTF-8');
textdomain('skosmos');

$this->model = new Model(new GlobalConfig('/../tests/testconfig.ttl'));
$this->model = new Model(new GlobalConfig('/../../tests/testconfig.ttl'));
$this->vocab = $this->model->getVocabulary('mapping');
$concepts = $this->vocab->getConceptInfo('http://www.skosmos.skos/mapping/m1', 'en');
$this->concept = $concepts[0];
Expand Down
2 changes: 1 addition & 1 deletion tests/ConceptPropertyTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ protected function setUp() : void
bind_textdomain_codeset('skosmos', 'UTF-8');
textdomain('skosmos');

$this->model = new Model(new GlobalConfig('/../tests/testconfig.ttl'));
$this->model = new Model(new GlobalConfig('/../../tests/testconfig.ttl'));
}

/**
Expand Down
2 changes: 1 addition & 1 deletion tests/ConceptPropertyValueLiteralTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ protected function setUp() : void
bind_textdomain_codeset('skosmos', 'UTF-8');
textdomain('skosmos');

$this->model = new Model(new GlobalConfig('/../tests/testconfig.ttl'));
$this->model = new Model(new GlobalConfig('/../../tests/testconfig.ttl'));
$this->vocab = $this->model->getVocabulary('test');
$results = $this->vocab->getConceptInfo('http://www.skosmos.skos/test/ta112', 'en');
$this->concept = reset($results);
Expand Down
2 changes: 1 addition & 1 deletion tests/ConceptPropertyValueTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ protected function setUp() : void
bind_textdomain_codeset('skosmos', 'UTF-8');
textdomain('skosmos');

$this->model = new Model(new GlobalConfig('/../tests/testconfig.ttl'));
$this->model = new Model(new GlobalConfig('/../../tests/testconfig.ttl'));
$this->vocab = $this->model->getVocabulary('test');
$results = $this->vocab->getConceptInfo('http://www.skosmos.skos/test/ta112', 'en');
$this->concept = reset($results);
Expand Down
Loading

0 comments on commit cc8d10e

Please sign in to comment.