Skip to content

Commit

Permalink
Move out of the Backend folder; Top-Level composer
Browse files Browse the repository at this point in the history
  • Loading branch information
felix-schindler committed Oct 27, 2022
1 parent e4f8395 commit c85a2a3
Show file tree
Hide file tree
Showing 28 changed files with 44 additions and 28 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
/Backend/Libraries/vendor/
vendor/
.DS_Store
6 changes: 4 additions & 2 deletions .phpstan.neon
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
parameters:
level: 6
excludePaths:
- Backend/Libraries/vendor/*
- vendor/*
paths:
- index.php
- Backend
- Controllers
- Core
- Views
2 changes: 1 addition & 1 deletion .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
{
"label": "PHPStan",
"type": "shell",
"command": "php Backend/Libraries/vendor/bin/phpstan analyse -c .phpstan.neon --memory-limit 500M",
"command": "php vendor/bin/phpstan analyse -c .phpstan.neon --memory-limit 500M",
"group": {
"kind": "build",
"isDefault": true
Expand Down
5 changes: 0 additions & 5 deletions Backend/Libraries/composer.json

This file was deleted.

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
3 changes: 3 additions & 0 deletions Backend/Core/Data/Database.php → Core/Data/Database.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ public function execute(string $queryStr, array $values): bool
* Reads data (row by row) from database
* Access returned value via $return['ColumnName']
*
* This should be executed if only one
* row is returned or in a do-while loop
*
* @see https://bugs.php.net/bug.php?edit=2&id=44341 Always string values!
* @throws PDOException When anything goes wrong
* @return array<string,string>|null Result as array - null on failure
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.
28 changes: 18 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,31 +1,39 @@
# Router

Since I'm mostly using [SvelteKit](https://github.com/sveltejs/kit) and [PocketBase](https://github.com/pocketbase/pocketbase), this Router is no longer maintained. Maybe when I'm getting bored, I'll fix / improve one or two things.
Since I'm mostly using [SvelteKit](https://github.com/sveltejs/kit) and
[PocketBase](https://github.com/pocketbase/pocketbase), this Router is no longer
actively maintained. When I'm bored, I might fix / improve a few things.

## Why use this?

- Dependency-free
- MVC
- No Models included, but you use PDO with the [Query class](/Backend/Core/Data/Query.php)
- Easy to use readable URLs like "/u/:name" instead of things like "user.php?name="
- No Models included, but you use PDO with the
[Query class](/Core/Data/Query.php) and
[Database class](/Core/Data/Database.php)
- Easy to use readable URLs like "/u/:name" instead of things like
"user.php?name="

## Getting started

1. Clone GitHub Repo - `git clone git@github.com:felix-schindler/Router.git && cd Router`
2. Run `php -S localhost:8080` or throw it on a web server
1. Clone GitHub Repo -
`git clone git@github.com:felix-schindler/Router.git && cd Router`
2. (Run `composer install` if you want to use `phpstan`)
3. Run `php -S localhost:8080` or throw it on a web server

## Requirements

- [PHP 8.1](https://www.php.net) with [PDO](https://www.php.net/manual/de/book.pdo.php)
- __OPTIONAL__: [Composer](https://getcomposer.org)
- [PHP 8.1](https://www.php.net) with
[PDO](https://www.php.net/manual/de/book.pdo.php)
- **OPTIONAL**: [Composer](https://getcomposer.org)

## Remove junk

This router is dependency-free. The only composer package installed is [PHPStan](https://phpstan.org), for static code analysis. Remove composer with
This router is dependency-free. The only composer package installed is
[PHPStan](https://phpstan.org), for static code analysis. Remove composer with

```zsh
rm -rf Backend/Libraries
rm .phpstan.neon
rm -rf composer* vendor/ .phpstan.neon
```

and remove the autoloader from the `index.php` file.
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
6 changes: 6 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"require": {
"php": "^8.1",
"phpstan/phpstan": "^1.2"
}
}
6 changes: 4 additions & 2 deletions Backend/Libraries/composer.lock → composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 7 additions & 7 deletions index.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

declare(strict_types = 1);
declare(strict_types=1);

$GLOBALS['start'] = microtime(true); // Meassure execution time -> look in Layout <footer>

Expand All @@ -18,14 +18,14 @@
define("DB_USER", "user");
define("DB_PASS", "pass");

define("TITLE", "Sample"); // Title for website
define("DOMAIN", "https://schindlerfelix.de"); // Hosted on this domain
define("TITLE", "Sample"); // Title for website
define("DOMAIN", "https://schindlerfelix.de"); // Hosted on this domain

// Require autoloaders
require_once("./Backend/Core/ClassLoader.php"); // Load classes
// require_once("./Backend/Libraries/vendor/autoload.php"); // Composer autoloader
require_once("./Core/ClassLoader.php"); // Load classes
// require_once("./vendor/autoload.php"); // Composer autoloader

// Application start
// session_start(); // Start PHP Session
// session_start(); // Start PHP Session (should only be executed if you use session variables)
ClassLoader::파람(); // Run the class loader
Router::艳颖(); // Run router
Router::艳颖(); // Run router

0 comments on commit c85a2a3

Please sign in to comment.