Skip to content

Commit

Permalink
updated php version, helpers and aliases
Browse files Browse the repository at this point in the history
  • Loading branch information
BenRutlandWeb committed Oct 13, 2021
1 parent fe5c4fb commit 53b054c
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 4 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
]
},
"require": {
"php": "^7.3",
"php": "^7.4|^8.0",
"radiate/framework": "^2.0"
},
"scripts": {
Expand Down
5 changes: 4 additions & 1 deletion functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,14 +101,17 @@
'Cache' => \Radiate\Support\Facades\Cache::class,
'Collection' => \Radiate\Support\Collection::class,
'Config' => \Radiate\Support\Facades\Config::class,
'Crypt' => \Radiate\Support\Facades\Crypt::class,
'DB' => \Radiate\Support\Facades\DB::class,
'Event' => \Radiate\Support\Facades\Event::class,
'File' => \Radiate\Support\Facades\File::class,
'Hash' => \Radiate\Support\Hash::class,
'Gate' => \Radiate\Support\Facades\Gate::class,
'Hash' => \Radiate\Support\Facades\Hash::class,
'Http' => \Radiate\Support\Facades\Http::class,
'Mail' => \Radiate\Support\Facades\Mail::class,
'Option' => \Radiate\Support\Facades\Option::class,
'Request' => \Radiate\Support\Facades\Request::class,
'Response' => \Radiate\Support\Facades\Response::class,
'Route' => \Radiate\Support\Facades\Route::class,
'Str' => \Radiate\Support\Str::class,
'URL' => \Radiate\Support\Facades\URL::class,
Expand Down
65 changes: 63 additions & 2 deletions helpers.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,26 @@
<?php

use Radiate\Support\Facades\App;
use Radiate\Foundation\Application;
use Radiate\Http\ResponseFactory;
use Radiate\View\Factory as ViewFactory;

if (!function_exists('app')) {
/**
* Get the available container instance.
*
* @param string|null $abstract
* @param array $parameters
* @return mixed|\Radiate\Foundation\Application
*/
function app(?string $abstract = null, array $parameters = [])
{
if (is_null($abstract)) {
return Application::getInstance();
}

return Application::getInstance()->make($abstract, $parameters);
}
}

if (!function_exists('base_path')) {
/**
Expand All @@ -11,7 +31,7 @@
*/
function base_path(?string $path = null)
{
return App::basePath($path);
return app()->basePath($path);
}
}

Expand All @@ -36,3 +56,44 @@ function env(string $key, $default = null)
return $default;
}
}

if (!function_exists('response')) {
/**
* Create a HTTP response
*
* @param mixed $content
* @param integer $status
* @param array $headers
* @return \Radiate\Http\ResponseFactory|\Radiate\Http\Response
*/
function response($content = '', int $status = 200, array $headers = [])
{
$factory = app(ResponseFactory::class);

if (func_num_args() === 0) {
return $factory;
}

return $factory->make($content, $status, $headers);
}
}

if (!function_exists('view')) {
/**
* Create a view
*
* @param string|null $view
* @param array $data
* @return \Radiate\View\Factory|\Radiate\View\View
*/
function view(?string $view = null, array $data = [])
{
$factory = app(ViewFactory::class);

if (func_num_args() === 0) {
return $factory;
}

return $factory->make($view, $data);
}
}

0 comments on commit 53b054c

Please sign in to comment.