<?php
namespace PHP\Echo\Dev;
use Tips\Daily;
echo new Daily('Frameworks|Vanilla');// /app/Controllers/Http/Controller.php
namespace App\Controllers\Http;
use Luminova\Base\Controller;
use Luminova\Attributes\Route;
use Luminova\Attributes\Prefix;
use App\Errors\Controllers\ErrorController;
#[Prefix(
pattern: '/(:base)',
exclude: ['api', 'admin'],
onError: [ErrorController::class, 'onWebError']
)]
class MainController extends Controller
{
#[Route('/', methods: ['ANY'], middleware: Route::HTTP_BEFORE_MIDDLEWARE)]
public function middleware(): int
{
return $this->app->session->isOnline()
? STATUS_SUCCESS
: STATUS_ERROR;
}
#[Route('/', methods: ['GET'])]
public function index(): int
{
return $this->view('index');
}
#[Route('/company/(:optional)', methods: ['GET'])]
public function company(?string $slug = null): int
{
return match($slug){
'team' => $this->view('teams'),
default => $this->view('about')
};
}
}// /routes/web.php
<?php
use Luminova\Interface\RouterInterface;
use App\Errors\Controllers\ErrorController;
$router->onError([ErrorController::class, 'onWebError']);
$router->middleware('ANY', '/(:root)', 'MainController::middleware');
$router->get('/', 'MainController::index');
$router->bind('/company/(:root)', function(RouterInterface $router) {
$router->get('/', 'MainController::about');
$router->get('/team', 'MainController::teams');
});<?php
use Luminova\Storages\Storage;
echo Storage::context(Storage::LOCAL)
->disk('foo')
->write('example.txt', 'Hello, World!');<?php
use Luminova\Storages\Storage;
echo Storage::context(Storage::AWS_S3)
->write('example.txt', 'Hello, World!')
->toLink();// /app/Application.php
namespace App;
use Luminova\Seo\Schema;
use Luminova\Foundation\Core\Application as CoreApplication;
class Application extends CoreApplication
{
protected ?Schema $schema = null;
public function onCreate()
{
$this->schema = new Schema();
$this->schema->setCanonical(APP_URL . $this->getView());
}
}<?php
// /app/Controllers/Http/Controller.php
namespace App\Controllers\Http;
use Luminova\Base\BaseController;
class Controller extends BaseController
{
public function index(): int
{
$this->app->schema->setObject([
'isArticle' => true,
'link' => $this->request->getUri(),
'headline' => 'This is the page description',
'title' => 'This page title',
'article_keywords' => ['Luminova', 'PHP'],
'word_count' => 28,
'author' => 'John Deo',
]);
return $this->view('index');
}
}<!-- /resources/Views/index.php -->
<!DOCTYPE html>
<html lang='en'>
<head>
<?= $this->schema->getMeta() . $this->schema->getScript();?>
<title><?= $this->schema->getTitle();?></title>
</head>
<body>
<div class='container'>
<h1>Your Website Intro</h1>
<p>Your Website Contents</p>
</div>
</body>
</html>use Luminova\Ai\Models\OpenAI;
use Luminova\Exceptions\AppException;
$openai = new OpenAI('your-api-key');
try {
$options = ['model' => 'gpt-3.5-turbo-instruct'];
$response = $openai->completion('Tell me a joke.', $options);
print_r($response);
} catch (AppException $e) {
echo 'Error: ' . $e->getMessage();
}use Luminova\Ai\Models\OpenAI;
$openai = new OpenAI('your-api-key');
try {
$url = $openai->image('Generate a female image holding a cup', [
'model' => 'dall-e-3',
'response_format' => 'url'
]);
echo $url;
} catch (AppException $e) {
echo 'Error: ' . $e->getMessage();
}// /app/Controller/Cli/Command.php
namespace App\Controllers\Cli;
use Luminova\Base\Command;
use Luminova\Attributes\Group;
use Luminova\Attributes\Route;
#[Group(name: 'demo')]
class DemoCommand extends Command
{
protected string $group = 'demo';
#[Route('ping', group: 'demo')]
#[Route('ping/count/(:int)', group: 'demo')]
public function ping(int $count = 1): int
{
$count = max(1, (int) ($this->option('count') ?? $count));
for ($i = 0; $i < $count; $i++) {
$this->writeln('pong');
usleep(500_000);
}
return STATUS_SUCCESS;
}
}// /routes/cli.php
<?php
use Luminova\Interface\RouterInterface;
$router->group('demo', function(RouterInterface $router) {
$router->command('ping/count/(:int)', 'Command::ping');
$router->command('ping', 'Command::ping');
});// Run the command with the default count (1 ping)
index.php demo ping
// Run the command with a custom count using a named argument
index.php demo ping count=10
// Run the command with a custom count using a flag
index.php demo ping --count=10Luminova method-based and Attribute routing is well designed and optimized, ensuing optimal application routing and rendering views.
With Luminova, you can easily switch from one storage to another. Vast cloud and locale storage system available for for your application.
Easy integration of schema object in your web pages. Generating your website xml sitemap with by running a simple NovaKit command.
Looking to create an AI powered application, try Luminova's OpenAI modes to interact with models like GhatGPT, and more...
Build your own command line tool, everything you need ranging from text formatting, applying color and executing system command.