diff --git a/app/bootstrap.php b/app/bootstrap.php index 0fd234e1ade..5f8ebf6c990 100644 --- a/app/bootstrap.php +++ b/app/bootstrap.php @@ -11,7 +11,7 @@ | */ -$app = new LaravelZero\Framework\Application( +$app = new Hyde\Framework\Application( dirname(__DIR__) ); diff --git a/bootstrap/app.php b/bootstrap/app.php index 4c64f9becbf..c03c82434b6 100644 --- a/bootstrap/app.php +++ b/bootstrap/app.php @@ -17,7 +17,7 @@ | */ -$app = new LaravelZero\Framework\Application( +$app = new Hyde\Framework\Application( dirname(__DIR__) ); diff --git a/build/tools/update-composer.php b/build/tools/update-composer.php index 4524a05181a..b25e785d179 100644 --- a/build/tools/update-composer.php +++ b/build/tools/update-composer.php @@ -33,5 +33,5 @@ file_put_contents('composer.json', json_encode($json, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES)); -echo "Done. Finished in " . number_format((microtime(true) - $time_start) * 1000, 2) . "ms\n"; +echo 'Done. Finished in '.number_format((microtime(true) - $time_start) * 1000, 2)."ms\n"; exit(0); diff --git a/composer.json b/composer.json index 5555a3cf838..743048ebea1 100644 --- a/composer.json +++ b/composer.json @@ -36,6 +36,11 @@ "Hyde\\Testing\\": "tests/" } }, + "scripts": { + "post-autoload-dump": [ + "@php hyde package:discover --ansi" + ] + }, "config": { "preferred-install": "dist", "sort-packages": true, diff --git a/packages/framework/src/Application.php b/packages/framework/src/Application.php new file mode 100644 index 00000000000..23ce8dabd83 --- /dev/null +++ b/packages/framework/src/Application.php @@ -0,0 +1,26 @@ +app->singleton(PackageManifest::class, function () { + return new PackageManifest( + new Filesystem, $this->basePath(), $this->basePath('storage/framework/cache/packages.php') + ); + }); + } +} diff --git a/packages/framework/src/Commands/HydePackageDiscoverCommand.php b/packages/framework/src/Commands/HydePackageDiscoverCommand.php new file mode 100644 index 00000000000..50892cf656f --- /dev/null +++ b/packages/framework/src/Commands/HydePackageDiscoverCommand.php @@ -0,0 +1,18 @@ +manifestPath = Hyde::path('storage/framework/cache/packages.php'); + parent::handle($manifest); + } +} diff --git a/packages/framework/src/HydeServiceProvider.php b/packages/framework/src/HydeServiceProvider.php index a8a5d112a4f..4feff093760 100644 --- a/packages/framework/src/HydeServiceProvider.php +++ b/packages/framework/src/HydeServiceProvider.php @@ -77,6 +77,8 @@ function () { Commands\HydeInstallCommand::class, Commands\HydeDebugCommand::class, Commands\HydeServeCommand::class, + + Commands\HydePackageDiscoverCommand::class, ]); } diff --git a/packages/realtime-compiler/bin/server.php b/packages/realtime-compiler/bin/server.php index 5bab4308fe4..48d574beffc 100644 --- a/packages/realtime-compiler/bin/server.php +++ b/packages/realtime-compiler/bin/server.php @@ -14,11 +14,10 @@ \Hyde\RealtimeCompiler\Http\ExceptionHandler::handle($exception); exit($exception->getCode()); } - } catch (\Throwable $th) { // Auxiliary exception handler echo '

Something went really wrong!

'; echo '

An error occurred that the core exception handler failed to process. Here\'s all we know:

'; - echo '

Initial exception:

' . print_r($exception, true).'
'; - echo '

Auxiliary exception:

' . print_r($th, true).'
'; -} \ No newline at end of file + echo '

Initial exception:

'.print_r($exception, true).'
'; + echo '

Auxiliary exception:

'.print_r($th, true).'
'; +} diff --git a/packages/realtime-compiler/src/Concerns/InteractsWithLaravel.php b/packages/realtime-compiler/src/Concerns/InteractsWithLaravel.php index 92097b51bdc..7f2a7e85625 100644 --- a/packages/realtime-compiler/src/Concerns/InteractsWithLaravel.php +++ b/packages/realtime-compiler/src/Concerns/InteractsWithLaravel.php @@ -26,7 +26,7 @@ protected function createApplication(): void protected function bootApplication(): void { - if (!isset($this->laravel)) { + if (! isset($this->laravel)) { $this->createApplication(); } diff --git a/projects/rocket/app/Exceptions/Handler.php b/projects/rocket/app/Exceptions/Handler.php index 62b59841c81..9d1bfc20de5 100644 --- a/projects/rocket/app/Exceptions/Handler.php +++ b/projects/rocket/app/Exceptions/Handler.php @@ -58,6 +58,7 @@ public function render($request, Throwable $exception) $whoops->writeToOutput(false); $whoops->pushHandler(new PrettyPageHandler()); $html = $whoops->handleException($exception); + return response()->make($html, 500); } diff --git a/projects/rocket/app/Http/Controllers/ApiController.php b/projects/rocket/app/Http/Controllers/ApiController.php index 7f926477160..96b47a4c1ce 100644 --- a/projects/rocket/app/Http/Controllers/ApiController.php +++ b/projects/rocket/app/Http/Controllers/ApiController.php @@ -15,7 +15,7 @@ public function pingRealtimeCompiler() ? response()->json(['success' => true]) : response()->json([ 'success' => false, - 'error' => 'Could not ping Realtime Compiler on default port 8080' + 'error' => 'Could not ping Realtime Compiler on default port 8080', ]); } @@ -24,9 +24,9 @@ public static function isRealtimeCompilerRunning() try { $client = new Client(['timeout' => 1]); $client->head('http://localhost:8080'); + return true; - } - catch (\Throwable) { + } catch (\Throwable) { return false; } } diff --git a/projects/rocket/app/Http/Controllers/DashboardController.php b/projects/rocket/app/Http/Controllers/DashboardController.php index 8aaa4882147..eaa5ce872d4 100644 --- a/projects/rocket/app/Http/Controllers/DashboardController.php +++ b/projects/rocket/app/Http/Controllers/DashboardController.php @@ -3,8 +3,8 @@ namespace Hyde\Rocket\Http\Controllers; use Hyde\Framework\Models\MarkdownPost; -use Hyde\Rocket\Models\Project; use Hyde\Framework\Services\CollectionService; +use Hyde\Rocket\Models\Project; class DashboardController extends Controller { @@ -31,10 +31,10 @@ public function index() protected function getContentList(): array { return array_merge([ - 'Blade Pages' => CollectionService::getBladePageList(), - 'Markdown Pages' => CollectionService::getMarkdownPageList(), - 'Markdown Posts' => CollectionService::getMarkdownPostList(), - 'Documentation Pages' => CollectionService::getDocumentationPageList(), + 'Blade Pages' => CollectionService::getBladePageList(), + 'Markdown Pages' => CollectionService::getMarkdownPageList(), + 'Markdown Posts' => CollectionService::getMarkdownPostList(), + 'Documentation Pages' => CollectionService::getDocumentationPageList(), ]); } } diff --git a/projects/rocket/app/Http/Controllers/DebugController.php b/projects/rocket/app/Http/Controllers/DebugController.php index aa29dc809e1..4205807b0e7 100644 --- a/projects/rocket/app/Http/Controllers/DebugController.php +++ b/projects/rocket/app/Http/Controllers/DebugController.php @@ -2,8 +2,8 @@ namespace Hyde\Rocket\Http\Controllers; -use Hyde\Rocket\Models\Project; use Hyde\Framework\Hyde; +use Hyde\Rocket\Models\Project; class DebugController extends Controller { @@ -19,7 +19,7 @@ public function __invoke() $information = [ 'Hyde/Framework version' => Hyde::version(), 'Hyde project path' => Hyde::path(), - 'PHP version' => phpversion() . ' (' . PHP_SAPI . ')', + 'PHP version' => phpversion().' ('.PHP_SAPI.')', 'Lumen version' => app()->version(), ]; dump($information); diff --git a/projects/rocket/app/Http/Controllers/FilesystemController.php b/projects/rocket/app/Http/Controllers/FilesystemController.php index 29d291d41e3..1369a4b9ba0 100644 --- a/projects/rocket/app/Http/Controllers/FilesystemController.php +++ b/projects/rocket/app/Http/Controllers/FilesystemController.php @@ -17,7 +17,7 @@ class FilesystemController extends Controller public function __construct() { if (strtoupper(substr(PHP_OS, 0, 3)) !== 'WIN') { - throw new \Exception('This API is only supported on Windows. ' . + throw new \Exception('This API is only supported on Windows. '. 'Please send a PR to open up support for other systems!'); } } @@ -26,27 +26,27 @@ public function open(Request $request) { if (! $request->has('path')) { return response()->json([ - 'error' => 'Missing path parameter.' + 'error' => 'Missing path parameter.', ], 400); } - $file = trim(Project::get()->path . '/' . $request->input('path'), '/'); + $file = trim(Project::get()->path.'/'.$request->input('path'), '/'); if (! file_exists($file)) { return response()->json([ - 'error' => 'File does not exist.' + 'error' => 'File does not exist.', ], 404); } if (is_dir($file)) { - shell_exec('explorer.exe "' . $file . '"'); + shell_exec('explorer.exe "'.$file.'"'); } else { - shell_exec('start "" "' . $file . '"'); + shell_exec('start "" "'.$file.'"'); } if ($request->expectsJson()) { return response()->json([ - 'success' => true + 'success' => true, ]); } diff --git a/projects/rocket/app/Http/Controllers/PostController.php b/projects/rocket/app/Http/Controllers/PostController.php index 1ce084fef22..a1d51771821 100644 --- a/projects/rocket/app/Http/Controllers/PostController.php +++ b/projects/rocket/app/Http/Controllers/PostController.php @@ -12,7 +12,7 @@ class PostController extends Controller { public function show(string $slug, Request $request) { - $path = Hyde::path($localPath = '_posts/' . $slug . '.md'); + $path = Hyde::path($localPath = '_posts/'.$slug.'.md'); if (! file_exists($path)) { return response('File not found.', 404); @@ -40,7 +40,7 @@ public function store(Request $request) $request->input('description'), $request->input('category'), $request->input('author') - ); + ); try { $creator->save(); @@ -50,12 +50,12 @@ public function store(Request $request) ]); } - return redirect('/_posts/' . $creator->slug . '?saved=true'); + return redirect('/_posts/'.$creator->slug.'?saved=true'); } public function update(string $slug, Request $request) { - $path = Hyde::path('_posts/' . $slug . '.md'); + $path = Hyde::path('_posts/'.$slug.'.md'); if (! file_exists($path)) { return response('File not found.', 404); @@ -63,6 +63,6 @@ public function update(string $slug, Request $request) file_put_contents($path, $request->get('markdown')); - return redirect('/_posts/' . $slug . '?saved=true'); + return redirect('/_posts/'.$slug.'?saved=true'); } } diff --git a/projects/rocket/app/Http/Controllers/RealtimeCompiler.php b/projects/rocket/app/Http/Controllers/RealtimeCompiler.php index de942aa7b87..3af8e31fa56 100644 --- a/projects/rocket/app/Http/Controllers/RealtimeCompiler.php +++ b/projects/rocket/app/Http/Controllers/RealtimeCompiler.php @@ -19,7 +19,7 @@ public function render(Request $request) { $path = $request->get('path', ''); - return redirect('http://localhost:8080/' . $path); + return redirect('http://localhost:8080/'.$path); } public function markdown(Request $request) @@ -32,7 +32,7 @@ public function markdown(Request $request) return view('markdown-preview', [ 'page' => basename($path), - 'markdown' => Str::markdown(YamlFrontMatter::markdownCompatibleParse(file_get_contents($path))->body()) + 'markdown' => Str::markdown(YamlFrontMatter::markdownCompatibleParse(file_get_contents($path))->body()), ]); } } diff --git a/projects/rocket/app/Models/Artisan.php b/projects/rocket/app/Models/Artisan.php index 6210df13750..9edc052ccb0 100644 --- a/projects/rocket/app/Models/Artisan.php +++ b/projects/rocket/app/Models/Artisan.php @@ -19,7 +19,7 @@ public function __construct(string $absoluteProjectPath) */ public function run(string $command): string { - return shell_exec('cd '.$this->path.' && php hyde ' . $command); + return shell_exec('cd '.$this->path.' && php hyde '.$command); } /** @@ -27,6 +27,6 @@ public function run(string $command): string */ public function passthru(string $command): void { - passthru('cd '.$this->path.' && php hyde ' . $command); + passthru('cd '.$this->path.' && php hyde '.$command); } } diff --git a/projects/rocket/app/Models/Project.php b/projects/rocket/app/Models/Project.php index ec71439706f..2404d4b7bcb 100644 --- a/projects/rocket/app/Models/Project.php +++ b/projects/rocket/app/Models/Project.php @@ -26,13 +26,14 @@ protected function __construct() protected function getPathOrFail(): string { - $path = realpath(getcwd() . '/../../'); - if (!is_dir($path)) { - throw new \Exception("Not a directory."); + $path = realpath(getcwd().'/../../'); + if (! is_dir($path)) { + throw new \Exception('Not a directory.'); } - if (!is_file($path . '/hyde')) { - throw new \Exception("Not a Hyde project."); + if (! is_file($path.'/hyde')) { + throw new \Exception('Not a Hyde project.'); } + return $path; } @@ -52,18 +53,17 @@ public function artisan(): Artisan */ public static function get(?string $property = null): mixed { - if (!isset(static::$instance)) { + if (! isset(static::$instance)) { static::$instance = new static(); } return isset($property) ? static::$instance->$property : static::$instance; - } protected function getVersion() { - return json_decode(file_get_contents($this->path . '/composer.json'))->require->{'hyde/framework'}; + return json_decode(file_get_contents($this->path.'/composer.json'))->require->{'hyde/framework'}; } } diff --git a/projects/rocket/app/Providers/AppServiceProvider.php b/projects/rocket/app/Providers/AppServiceProvider.php index ddab1a1f91a..2ec53523e45 100644 --- a/projects/rocket/app/Providers/AppServiceProvider.php +++ b/projects/rocket/app/Providers/AppServiceProvider.php @@ -14,12 +14,12 @@ class AppServiceProvider extends ServiceProvider */ public function register() { - $this->app->singleton(\Desilva\Console\Contracts\Console::class, function() { + $this->app->singleton(\Desilva\Console\Contracts\Console::class, function () { return new \Desilva\Console\Console; }); } -/** + /** * Bootstrap any application services. * * @return void diff --git a/projects/rocket/bootstrap/app.php b/projects/rocket/bootstrap/app.php index 90d4da46c79..7a5d9e82c57 100644 --- a/projects/rocket/bootstrap/app.php +++ b/projects/rocket/bootstrap/app.php @@ -8,7 +8,6 @@ date_default_timezone_set(env('APP_TIMEZONE', 'UTC')); - /* |-------------------------------------------------------------------------- | Create The Application diff --git a/projects/rocket/routes/web.php b/projects/rocket/routes/web.php index 3d757fb65ed..e0bb97eb536 100644 --- a/projects/rocket/routes/web.php +++ b/projects/rocket/routes/web.php @@ -29,7 +29,6 @@ $router->get('/create-post', 'PostController@create'); $router->post('/create-post', 'PostController@store'); - $router->post('/fileapi/open', 'FilesystemController@open'); $router->get('/open/_site', 'RealtimeCompiler@render'); $router->get('/render/markdown', 'RealtimeCompiler@markdown'); diff --git a/projects/rocket/tests/ExampleTest.php b/projects/rocket/tests/ExampleTest.php index 1c265d4a0f6..860cd229ae0 100644 --- a/projects/rocket/tests/ExampleTest.php +++ b/projects/rocket/tests/ExampleTest.php @@ -2,9 +2,6 @@ namespace Tests; -use Laravel\Lumen\Testing\DatabaseMigrations; -use Laravel\Lumen\Testing\DatabaseTransactions; - class ExampleTest extends TestCase { /** diff --git a/projects/shelf/single-file-dashboard/dashboard.php b/projects/shelf/single-file-dashboard/dashboard.php index 4a75032b9f9..67bd828a5c5 100644 --- a/projects/shelf/single-file-dashboard/dashboard.php +++ b/projects/shelf/single-file-dashboard/dashboard.php @@ -1,7 +1,6 @@ HTTP/1.1 403 - Access Denied'; echo '

You must be on localhost to access this page. Refusing to serve request.

'; @@ -26,72 +25,71 @@ try { // Create the Laravel app, and boot it up -try { - $app = require_once sprintf('%s/app/bootstrap.php', BASE_PATH); -} catch (\Throwable $th) { - try { - $app = require_once sprintf('%s/bootstrap/app.php', BASE_PATH); - } catch (\Throwable $th) { - throw $th; - } -} -$kernel = $app->make(Illuminate\Contracts\Console\Kernel::class); -$kernel->bootstrap(); -Hyde::setBasePath(BASE_PATH); - -// Create the Hyde interface -$hyde = new class() extends Hyde {}; + try { + $app = require_once sprintf('%s/app/bootstrap.php', BASE_PATH); + } catch (\Throwable $th) { + try { + $app = require_once sprintf('%s/bootstrap/app.php', BASE_PATH); + } catch (\Throwable $th) { + throw $th; + } + } + $kernel = $app->make(Illuminate\Contracts\Console\Kernel::class); + $kernel->bootstrap(); + Hyde::setBasePath(BASE_PATH); -// Create the project configuration class -$project = new class -{ - public string $path; - public string $name; + // Create the Hyde interface + $hyde = new class() extends Hyde {}; - public function __construct() + // Create the project configuration class + $project = new class { - $this->path = BASE_PATH; - $this->name = config('hyde.name', ucwords(str_replace('-', ' ', basename(BASE_PATH)))); - } -}; + public string $path; + public string $name; -// Set the app name -$appname = e($project->name) . ' CMS'; + public function __construct() + { + $this->path = BASE_PATH; + $this->name = config('hyde.name', ucwords(str_replace('-', ' ', basename(BASE_PATH)))); + } + }; + // Set the app name + $appname = e($project->name).' CMS'; -// Get the request page -$page = $_GET['page'] ?? 'index'; -if ($page === 'dashboard' || $page === '' ) { - $page = 'index'; -} + // Get the request page + $page = $_GET['page'] ?? 'index'; + if ($page === 'dashboard' || $page === '') { + $page = 'index'; + } -// Key => label -$routes = [ - 'index' => 'Dashboard', - '404' => '404 Page Not Found', - 'manual'=> 'Manual', - 'file-viewer' => 'File Viewer', -]; + // Key => label + $routes = [ + 'index' => 'Dashboard', + '404' => '404 Page Not Found', + 'manual'=> 'Manual', + 'file-viewer' => 'File Viewer', + ]; -if (! isset($routes[$page])) { - header('HTTP/1.1 404 Not Found'); - $page = '404'; -} + if (! isset($routes[$page])) { + header('HTTP/1.1 404 Not Found'); + $page = '404'; + } -// Set the page name -$pagename = $appname .' - '. $routes[$page]; + // Set the page name + $pagename = $appname.' - '.$routes[$page]; -// Helper functions -function icon(string $name) { - $icons = [ - 'blade' => 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQAQMAAAAlPW0iAAAACXBIWXMAAAPoAAAD6AG1e1JrAAAABlBMVEX/LR//LB96KezJAAAAAnRSTlN3CW8xmq0AAAA7SURBVAjXATAAz/8Ax/8AOfcAGcMARZwAbYgAbaYAbbYAbBEAbOMAY8cAZzcAcHcAPecAzZ8A8H8A+P+i4xJQuZ3gxwAAAABJRU5ErkJggg==', - 'markdown' => 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAKAQMAAACHcEzfAAAACXBIWXMAAAPoAAAD6AG1e1JrAAAABlBMVEVCQkJBQUFtOGGCAAAAAnRSTlPBCd2uk5MAAAAiSURBVAjXY2BgYKj/x+D3jMEljcEBiJwY/NIY/P6BBBkYAHYfCAEd79fPAAAAAElFTkSuQmCC', - 'documentation' => 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQAQMAAAAlPW0iAAAACXBIWXMAAAPoAAAD6AG1e1JrAAAABlBMVEVXV1dUVFSxYS6RAAAAAnRSTlPnEHobuHcAAAArSURBVAjXY/j/nwGIHsgzPPBneJDO8KCc4QEzCD1+zPD4MJQBEXnADlQJABfcFU91j91PAAAAAElFTkSuQmCC', - ]; + // Helper functions + function icon(string $name) + { + $icons = [ + 'blade' => 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQAQMAAAAlPW0iAAAACXBIWXMAAAPoAAAD6AG1e1JrAAAABlBMVEX/LR//LB96KezJAAAAAnRSTlN3CW8xmq0AAAA7SURBVAjXATAAz/8Ax/8AOfcAGcMARZwAbYgAbaYAbbYAbBEAbOMAY8cAZzcAcHcAPecAzZ8A8H8A+P+i4xJQuZ3gxwAAAABJRU5ErkJggg==', + 'markdown' => 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAKAQMAAACHcEzfAAAACXBIWXMAAAPoAAAD6AG1e1JrAAAABlBMVEVCQkJBQUFtOGGCAAAAAnRSTlPBCd2uk5MAAAAiSURBVAjXY2BgYKj/x+D3jMEljcEBiJwY/NIY/P6BBBkYAHYfCAEd79fPAAAAAElFTkSuQmCC', + 'documentation' => 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQAQMAAAAlPW0iAAAACXBIWXMAAAPoAAAD6AG1e1JrAAAABlBMVEVXV1dUVFSxYS6RAAAAAnRSTlPnEHobuHcAAAArSURBVAjXY/j/nwGIHsgzPPBneJDO8KCc4QEzCD1+zPD4MJQBEXnADlQJABfcFU91j91PAAAAAElFTkSuQmCC', + ]; - return $icons[$name] ?? ''; -} -?> + return $icons[$name] ?? ''; + } ?> @@ -228,7 +226,7 @@ function icon(string $name) {

- +

Project Information

@@ -290,90 +288,96 @@ function icon(string $name) { - + Blade - view ?> + view ?> - view . BladePage::$fileExtension ?> + view.BladePage::$fileExtension ?> - + - + Markdown - title ?> + title ?> - slug . MarkdownPage::$fileExtension ?> + slug.MarkdownPage::$fileExtension ?> - + - +
- +
type = $this->qualifyType($type); - $this->filename = urldecode($file); - $this->contentpath = $this->getContentpath(); - $this->filepath = Hyde::path($this->contentpath); - } + public function __construct(string $type, string $file) + { + $this->type = $this->qualifyType($type); + $this->filename = urldecode($file); + $this->contentpath = $this->getContentpath(); + $this->filepath = Hyde::path($this->contentpath); + } - protected function qualifyType(string $type) { - $type = strtolower($type); - if ($type === 'bladepage') { - return BladePage::class; - } elseif ($type === 'markdownpage') { - return MarkdownPage::class; - } elseif ($type === 'documentationpage') { - return DocumentationPage::class; - } elseif ($type === 'markdownpost') { - return MarkdownPost::class; - } else { - throw new UnsupportedPageTypeException('Invalid file type'); - } - } + protected function qualifyType(string $type) + { + $type = strtolower($type); + if ($type === 'bladepage') { + return BladePage::class; + } elseif ($type === 'markdownpage') { + return MarkdownPage::class; + } elseif ($type === 'documentationpage') { + return DocumentationPage::class; + } elseif ($type === 'markdownpost') { + return MarkdownPost::class; + } else { + throw new UnsupportedPageTypeException('Invalid file type'); + } + } - protected function getContentpath() { - $class = $this->type; - $filename = $this->filename; - $filepath = $class::$sourceDirectory .'/'. $filename . $class::$fileExtension; - if (!file_exists(Hyde::path($filepath))) { - throw new FileNotFoundException($filepath); - } - return $filepath; - } + protected function getContentpath() + { + $class = $this->type; + $filename = $this->filename; + $filepath = $class::$sourceDirectory.'/'.$filename.$class::$fileExtension; + if (! file_exists(Hyde::path($filepath))) { + throw new FileNotFoundException($filepath); + } - public function getContents() { - return file_get_contents($this->filepath); - } + return $filepath; + } + + public function getContents() + { + return file_get_contents($this->filepath); + } }; ?> @@ -399,7 +403,7 @@ public function getContents() {
getContents()) ?>
-
@@ -417,9 +421,9 @@ public function getContents() { - + Go Back to dashboard? - + @@ -451,12 +455,11 @@ public function getContents() { Error'; - echo '

An error occurred while processing your request.

'; - echo '
'.$th->getMessage().'
'; - echo '

Extra information:

'; - echo '
'.$th->getTraceAsString().print_r($th, true).'
'; - exit($th->getCode()); -} + echo '

Error

'; + echo '

An error occurred while processing your request.

'; + echo '
'.$th->getMessage().'
'; + echo '

Extra information:

'; + echo '
'.$th->getTraceAsString().print_r($th, true).'
'; + exit($th->getCode()); + } diff --git a/tests/Feature/AuthorHelperTest.php b/tests/Feature/AuthorHelperTest.php index 5c3cb3bf36c..fdb8a80eebe 100644 --- a/tests/Feature/AuthorHelperTest.php +++ b/tests/Feature/AuthorHelperTest.php @@ -4,9 +4,9 @@ use Hyde\Framework\Helpers\Author as AuthorHelper; use Hyde\Framework\Models\Author as AuthorModel; +use Hyde\Testing\TestCase; use Illuminate\Support\Collection; use Illuminate\Support\Facades\Config; -use Hyde\Testing\TestCase; /** * Class AuthorHelperTest. diff --git a/tests/Feature/AuthorPostsIntegrationTest.php b/tests/Feature/AuthorPostsIntegrationTest.php index 6b97c4b3e2b..a2515d011ea 100644 --- a/tests/Feature/AuthorPostsIntegrationTest.php +++ b/tests/Feature/AuthorPostsIntegrationTest.php @@ -5,8 +5,8 @@ use Hyde\Framework\Actions\CreatesNewMarkdownPostFile; use Hyde\Framework\Helpers\Author; use Hyde\Framework\Hyde; -use Illuminate\Support\Facades\Config; use Hyde\Testing\TestCase; +use Illuminate\Support\Facades\Config; /** * Test that the Author feature works in diff --git a/tests/Feature/BuildOutputDirectoryCanBeChangedTest.php b/tests/Feature/BuildOutputDirectoryCanBeChangedTest.php index 257c57191f2..c0048c8ff29 100644 --- a/tests/Feature/BuildOutputDirectoryCanBeChangedTest.php +++ b/tests/Feature/BuildOutputDirectoryCanBeChangedTest.php @@ -5,8 +5,8 @@ use Hyde\Framework\Hyde; use Hyde\Framework\Services\RebuildService; use Hyde\Framework\StaticPageBuilder; -use Illuminate\Support\Facades\File; use Hyde\Testing\TestCase; +use Illuminate\Support\Facades\File; /** * Class BuildOutputDirectoryCanBeChangedTest. diff --git a/tests/Feature/Commands/HydeUpdateConfigsCommandTest.php b/tests/Feature/Commands/HydeUpdateConfigsCommandTest.php index af6a46e1e92..cfa8c22098e 100644 --- a/tests/Feature/Commands/HydeUpdateConfigsCommandTest.php +++ b/tests/Feature/Commands/HydeUpdateConfigsCommandTest.php @@ -4,8 +4,8 @@ use Hyde\Framework\Commands\HydeUpdateConfigsCommand; use Hyde\Framework\Hyde; -use Illuminate\Support\Facades\File; use Hyde\Testing\TestCase; +use Illuminate\Support\Facades\File; /** * @covers \Hyde\Framework\Commands\HydeUpdateConfigsCommand diff --git a/tests/Feature/Concerns/GeneratesPageMetadataTest.php b/tests/Feature/Concerns/GeneratesPageMetadataTest.php index 8d1ca3b32a0..cfde517792c 100644 --- a/tests/Feature/Concerns/GeneratesPageMetadataTest.php +++ b/tests/Feature/Concerns/GeneratesPageMetadataTest.php @@ -3,8 +3,8 @@ namespace Hyde\Testing\Feature\Concerns; use Hyde\Framework\Concerns\GeneratesPageMetadata; -use Illuminate\Support\Facades\Config; use Hyde\Testing\TestCase; +use Illuminate\Support\Facades\Config; /** * @covers \Hyde\Framework\Concerns\GeneratesPageMetadata diff --git a/tests/Feature/ConfigurableFeaturesTest.php b/tests/Feature/ConfigurableFeaturesTest.php index bf22b1e300f..ac89ca415b3 100644 --- a/tests/Feature/ConfigurableFeaturesTest.php +++ b/tests/Feature/ConfigurableFeaturesTest.php @@ -3,8 +3,8 @@ namespace Hyde\Testing\Feature; use Hyde\Framework\Helpers\Features; -use Illuminate\Support\Facades\Config; use Hyde\Testing\TestCase; +use Illuminate\Support\Facades\Config; /** * @covers \Hyde\Framework\Helpers\Features diff --git a/tests/Feature/DarkmodeFeatureTest.php b/tests/Feature/DarkmodeFeatureTest.php index 6a227d5ea66..6f1f9d5e995 100644 --- a/tests/Feature/DarkmodeFeatureTest.php +++ b/tests/Feature/DarkmodeFeatureTest.php @@ -5,8 +5,8 @@ use Hyde\Framework\Helpers\Features; use Hyde\Framework\Models\DocumentationPage; use Hyde\Framework\Models\MarkdownPage; -use Illuminate\Support\Facades\Config; use Hyde\Testing\TestCase; +use Illuminate\Support\Facades\Config; /** * @covers \Hyde\Framework\Helpers\Features::darkmode diff --git a/tests/Feature/FindsContentLengthForImageObjectTest.php b/tests/Feature/FindsContentLengthForImageObjectTest.php index f9ad06a5497..d654f97000e 100644 --- a/tests/Feature/FindsContentLengthForImageObjectTest.php +++ b/tests/Feature/FindsContentLengthForImageObjectTest.php @@ -3,9 +3,9 @@ namespace Hyde\Testing\Feature; use Hyde\Framework\Models\Image; +use Hyde\Testing\TestCase; use Illuminate\Http\Client\Request; use Illuminate\Support\Facades\Http; -use Hyde\Testing\TestCase; /** * @covers \Hyde\Framework\Actions\FindsContentLengthForImageObject diff --git a/tests/Feature/GeneratesNavigationMenuTest.php b/tests/Feature/GeneratesNavigationMenuTest.php index c3c833277e0..e42d240fd62 100644 --- a/tests/Feature/GeneratesNavigationMenuTest.php +++ b/tests/Feature/GeneratesNavigationMenuTest.php @@ -4,9 +4,9 @@ use Hyde\Framework\Actions\GeneratesNavigationMenu; use Hyde\Framework\Hyde; +use Hyde\Testing\TestCase; use Illuminate\Support\Arr; use Illuminate\Support\Facades\Config; -use Hyde\Testing\TestCase; class GeneratesNavigationMenuTest extends TestCase { diff --git a/tests/Feature/MarkdownPageTest.php b/tests/Feature/MarkdownPageTest.php index 436ed9ab952..a361b9eab24 100644 --- a/tests/Feature/MarkdownPageTest.php +++ b/tests/Feature/MarkdownPageTest.php @@ -7,8 +7,8 @@ use Hyde\Framework\Models\MarkdownPage; use Hyde\Framework\Models\Parsers\MarkdownPageParser; use Hyde\Framework\Services\CollectionService; -use Illuminate\Support\Facades\File; use Hyde\Testing\TestCase; +use Illuminate\Support\Facades\File; /** * Test the Markdown page parser. diff --git a/tests/Feature/Services/DocumentationSidebarServiceTest.php b/tests/Feature/Services/DocumentationSidebarServiceTest.php index 5de8c2251e8..a7098ab0352 100644 --- a/tests/Feature/Services/DocumentationSidebarServiceTest.php +++ b/tests/Feature/Services/DocumentationSidebarServiceTest.php @@ -7,9 +7,9 @@ use Hyde\Framework\Models\DocumentationSidebar; use Hyde\Framework\Models\DocumentationSidebarItem; use Hyde\Framework\Services\DocumentationSidebarService; +use Hyde\Testing\TestCase; use Illuminate\Support\Facades\Config; use Illuminate\Support\Facades\File; -use Hyde\Testing\TestCase; /** * @covers \Hyde\Framework\Services\DocumentationSidebarService diff --git a/tests/Feature/Services/HasConfigurableMarkdownFeaturesTest.php b/tests/Feature/Services/HasConfigurableMarkdownFeaturesTest.php index c52b7f8cede..fde9b90998f 100644 --- a/tests/Feature/Services/HasConfigurableMarkdownFeaturesTest.php +++ b/tests/Feature/Services/HasConfigurableMarkdownFeaturesTest.php @@ -4,8 +4,8 @@ use Hyde\Framework\Concerns\Markdown\HasConfigurableMarkdownFeatures; use Hyde\Framework\Models\DocumentationPage; -use Illuminate\Support\Facades\Config; use Hyde\Testing\TestCase; +use Illuminate\Support\Facades\Config; /** * @covers \Hyde\Framework\Concerns\Markdown\HasConfigurableMarkdownFeatures diff --git a/tests/Feature/Services/SitemapServiceTest.php b/tests/Feature/Services/SitemapServiceTest.php index e6912a15d92..044f77104cd 100644 --- a/tests/Feature/Services/SitemapServiceTest.php +++ b/tests/Feature/Services/SitemapServiceTest.php @@ -4,8 +4,8 @@ use Hyde\Framework\Hyde; use Hyde\Framework\Services\SitemapService; -use Illuminate\Support\Facades\File; use Hyde\Testing\TestCase; +use Illuminate\Support\Facades\File; /** * @covers \Hyde\Framework\Services\SitemapService diff --git a/tests/Feature/StaticPageBuilderTest.php b/tests/Feature/StaticPageBuilderTest.php index 169abb6dfb6..0c45a07df70 100644 --- a/tests/Feature/StaticPageBuilderTest.php +++ b/tests/Feature/StaticPageBuilderTest.php @@ -9,9 +9,9 @@ use Hyde\Framework\Models\MarkdownPage; use Hyde\Framework\Models\MarkdownPost; use Hyde\Framework\StaticPageBuilder; +use Hyde\Testing\TestCase; use Illuminate\Support\Facades\Config; use Illuminate\Support\Facades\File; -use Hyde\Testing\TestCase; /** * Feature tests for the StaticPageBuilder class. diff --git a/tests/TestListener.php b/tests/TestListener.php index 4b0e47c56bd..4a8d95da968 100644 --- a/tests/TestListener.php +++ b/tests/TestListener.php @@ -11,7 +11,6 @@ class TestListener implements \PHPUnit\Framework\TestListener { - public function addError(Test $test, Throwable $t, float $time): void { // @@ -63,4 +62,4 @@ public function endTest(Test $test, float $time): void { // } -} \ No newline at end of file +} diff --git a/tests/Unit/BlogPostFrontMatterIsOptionalTest.php b/tests/Unit/BlogPostFrontMatterIsOptionalTest.php index 5f7aecf052d..74fb5e07a37 100644 --- a/tests/Unit/BlogPostFrontMatterIsOptionalTest.php +++ b/tests/Unit/BlogPostFrontMatterIsOptionalTest.php @@ -3,8 +3,8 @@ namespace Hyde\Testing\Unit; use Hyde\Framework\Hyde; -use Illuminate\Support\Facades\Artisan; use Hyde\Testing\TestCase; +use Illuminate\Support\Facades\Artisan; class BlogPostFrontMatterIsOptionalTest extends TestCase { diff --git a/tests/Unit/DiscoveryServiceCanFindModelFromCustomSourceFilePathTest.php b/tests/Unit/DiscoveryServiceCanFindModelFromCustomSourceFilePathTest.php index 333bc4f72bf..ce2d67317d7 100644 --- a/tests/Unit/DiscoveryServiceCanFindModelFromCustomSourceFilePathTest.php +++ b/tests/Unit/DiscoveryServiceCanFindModelFromCustomSourceFilePathTest.php @@ -7,8 +7,8 @@ use Hyde\Framework\Models\MarkdownPage; use Hyde\Framework\Models\MarkdownPost; use Hyde\Framework\Services\DiscoveryService; -use Illuminate\Support\Facades\Config; use Hyde\Testing\TestCase; +use Illuminate\Support\Facades\Config; /** * Class DiscoveryServiceCanFindModelFromCustomSourceFilePathTest. diff --git a/tests/Unit/GetLatestMarkdownPostsTest.php b/tests/Unit/GetLatestMarkdownPostsTest.php index a818ea50c92..3c350395380 100644 --- a/tests/Unit/GetLatestMarkdownPostsTest.php +++ b/tests/Unit/GetLatestMarkdownPostsTest.php @@ -4,8 +4,8 @@ use Hyde\Framework\Hyde; use Hyde\Framework\Models\MarkdownPost; -use Illuminate\Support\Collection; use Hyde\Testing\TestCase; +use Illuminate\Support\Collection; /** * @see \Hyde\Framework\Models\MarkdownPost::latest() diff --git a/tests/Unit/HasMarkdownFeaturesTest.php b/tests/Unit/HasMarkdownFeaturesTest.php index 1e93bcf1e67..90b2ddd7466 100644 --- a/tests/Unit/HasMarkdownFeaturesTest.php +++ b/tests/Unit/HasMarkdownFeaturesTest.php @@ -3,8 +3,8 @@ namespace Hyde\Testing\Unit; use Hyde\Framework\Concerns\Markdown\HasMarkdownFeatures; -use Illuminate\Support\Facades\Config; use Hyde\Testing\TestCase; +use Illuminate\Support\Facades\Config; /** * @covers \Hyde\Framework\Concerns\Markdown\HasMarkdownFeatures diff --git a/tests/Unit/HydeGetLatestPostsHelperTest.php b/tests/Unit/HydeGetLatestPostsHelperTest.php index a69c1703330..db08f855e4a 100644 --- a/tests/Unit/HydeGetLatestPostsHelperTest.php +++ b/tests/Unit/HydeGetLatestPostsHelperTest.php @@ -4,8 +4,8 @@ use Hyde\Framework\Hyde; use Hyde\Framework\Models\MarkdownPost; -use Illuminate\Support\Collection; use Hyde\Testing\TestCase; +use Illuminate\Support\Collection; /** * @deprecated as parent method is deprecated diff --git a/tests/Unit/HydePathHelperTest.php b/tests/Unit/HydePathHelperTest.php index a336fd942a1..39a14c61284 100644 --- a/tests/Unit/HydePathHelperTest.php +++ b/tests/Unit/HydePathHelperTest.php @@ -22,36 +22,35 @@ public function test_string_is_returned() $this->assertIsString(Hyde::path()); } - public function test_returned_directory_contains_content_expected_to_be_in_the_project_directory() { $this->assertTrue( - file_exists(Hyde::path() . DIRECTORY_SEPARATOR . 'hyde') && - file_exists(Hyde::path() . DIRECTORY_SEPARATOR . '_pages') && - file_exists(Hyde::path() . DIRECTORY_SEPARATOR . '_posts') && - file_exists(Hyde::path() . DIRECTORY_SEPARATOR . '_site') + file_exists(Hyde::path().DIRECTORY_SEPARATOR.'hyde') && + file_exists(Hyde::path().DIRECTORY_SEPARATOR.'_pages') && + file_exists(Hyde::path().DIRECTORY_SEPARATOR.'_posts') && + file_exists(Hyde::path().DIRECTORY_SEPARATOR.'_site') ); } public function test_method_returns_qualified_file_path_when_supplied_with_argument() { - $this->assertEquals(Hyde::path('file.php'), Hyde::path() . DIRECTORY_SEPARATOR . 'file.php'); + $this->assertEquals(Hyde::path('file.php'), Hyde::path().DIRECTORY_SEPARATOR.'file.php'); } public function test_method_strips_trailing_directory_separators_from_argument() { - $this->assertEquals(Hyde::path('\\/file.php/'), Hyde::path() . DIRECTORY_SEPARATOR . 'file.php'); + $this->assertEquals(Hyde::path('\\/file.php/'), Hyde::path().DIRECTORY_SEPARATOR.'file.php'); } public function test_method_returns_expected_value_for_nested_path_arguments() { - $this->assertEquals(Hyde::path('directory/file.php'), Hyde::path() . DIRECTORY_SEPARATOR . 'directory/file.php'); + $this->assertEquals(Hyde::path('directory/file.php'), Hyde::path().DIRECTORY_SEPARATOR.'directory/file.php'); } public function test_method_returns_expected_value_regardless_of_trailing_directory_separators_in_argument() { - $this->assertEquals(Hyde::path('directory/file.php/'), Hyde::path() . DIRECTORY_SEPARATOR . 'directory/file.php'); - $this->assertEquals(Hyde::path('/directory/file.php/'), Hyde::path() . DIRECTORY_SEPARATOR . 'directory/file.php'); - $this->assertEquals(Hyde::path('\\/directory/file.php/'), Hyde::path() . DIRECTORY_SEPARATOR . 'directory/file.php'); + $this->assertEquals(Hyde::path('directory/file.php/'), Hyde::path().DIRECTORY_SEPARATOR.'directory/file.php'); + $this->assertEquals(Hyde::path('/directory/file.php/'), Hyde::path().DIRECTORY_SEPARATOR.'directory/file.php'); + $this->assertEquals(Hyde::path('\\/directory/file.php/'), Hyde::path().DIRECTORY_SEPARATOR.'directory/file.php'); } } diff --git a/tests/Unit/InteractsWithDirectoriesConcernTest.php b/tests/Unit/InteractsWithDirectoriesConcernTest.php index a795c014572..3ba4be2dc13 100644 --- a/tests/Unit/InteractsWithDirectoriesConcernTest.php +++ b/tests/Unit/InteractsWithDirectoriesConcernTest.php @@ -4,8 +4,8 @@ use Hyde\Framework\Concerns\InteractsWithDirectories; use Hyde\Framework\Hyde; -use Illuminate\Support\Facades\File; use Hyde\Testing\TestCase; +use Illuminate\Support\Facades\File; /** * Class InteractsWithDirectoriesConcernTest. diff --git a/tests/Unit/PageModelGetHelperTest.php b/tests/Unit/PageModelGetHelperTest.php index bd78b667419..566712ca9ea 100644 --- a/tests/Unit/PageModelGetHelperTest.php +++ b/tests/Unit/PageModelGetHelperTest.php @@ -7,8 +7,8 @@ use Hyde\Framework\Models\DocumentationPage; use Hyde\Framework\Models\MarkdownPage; use Hyde\Framework\Models\MarkdownPost; -use Illuminate\Support\Collection; use Hyde\Testing\TestCase; +use Illuminate\Support\Collection; /** * @see \Hyde\Framework\Concerns\AbstractPage::all() diff --git a/tests/Unit/SourceFilesInCustomDirectoriesCanBeCompiledTest.php b/tests/Unit/SourceFilesInCustomDirectoriesCanBeCompiledTest.php index 30ca3b14e4f..086f5cde265 100644 --- a/tests/Unit/SourceFilesInCustomDirectoriesCanBeCompiledTest.php +++ b/tests/Unit/SourceFilesInCustomDirectoriesCanBeCompiledTest.php @@ -9,9 +9,9 @@ use Hyde\Framework\Models\MarkdownPost; use Hyde\Framework\Services\DiscoveryService; use Hyde\Framework\StaticPageBuilder; +use Hyde\Testing\TestCase; use Illuminate\Support\Facades\Config; use Illuminate\Support\Facades\File; -use Hyde\Testing\TestCase; /** * Class SourceFilesInCustomDirectoriesCanBeCompiledTest. diff --git a/tests/Unit/Views/ArticleExcerptViewTest.php b/tests/Unit/Views/ArticleExcerptViewTest.php index 2ddd1d30abc..6fd45bad79f 100644 --- a/tests/Unit/Views/ArticleExcerptViewTest.php +++ b/tests/Unit/Views/ArticleExcerptViewTest.php @@ -4,8 +4,8 @@ use Hyde\Framework\Hyde; use Hyde\Framework\Models\MarkdownPost; -use Illuminate\Support\Facades\Blade; use Hyde\Testing\TestCase; +use Illuminate\Support\Facades\Blade; /** * @see resources/views/components/article-excerpt.blade.php