First Commit

This commit is contained in:
marco
2026-09-04 14:54:13 -03:00
commit 9c54bd3ac7
4914 changed files with 789004 additions and 0 deletions
+65
View File
@@ -0,0 +1,65 @@
<?php
namespace App\Console\Command;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Dotenv\Dotenv;
class GenerateApiKeysCommand extends Command
{
protected static $defaultName = 'generate:api-keys';
protected function configure()
{
$this->setDescription('Generates API keys and writes them to the .env file');
}
protected function execute(InputInterface $input, OutputInterface $output)
{
// Generate random API keys
$publicKey = bin2hex(random_bytes(16)); // Generates a random public key
$secretKey = bin2hex(random_bytes(32)); // Generates a random secret key
// Output to terminal
$output->writeln("Public Key: $publicKey");
$output->writeln("Secret Key: $secretKey");
// Path to the .env file
$envFilePath = __DIR__ . '/../../../.env';
// Check if the .env file exists
if (!file_exists($envFilePath)) {
$output->writeln("<error>.env file not found!</error>");
return Command::FAILURE;
}
// Read the contents of the .env file
$envFile = file_get_contents($envFilePath);
// Check if the keys already exist in the .env file
if (strpos($envFile, 'API_PUBLIC_KEY=') === false) {
// Add the public key
$envFile .= "\nAPI_PUBLIC_KEY=$publicKey";
} else {
// Replace the existing public key
$envFile = preg_replace('/^API_PUBLIC_KEY=.*$/m', "API_PUBLIC_KEY=$publicKey", $envFile);
}
if (strpos($envFile, 'API_SECRET_KEY=') === false) {
// Add the secret key
$envFile .= "\nAPI_SECRET_KEY=$secretKey";
} else {
// Replace the existing secret key
$envFile = preg_replace('/^API_SECRET_KEY=.*$/m', "API_SECRET_KEY=$secretKey", $envFile);
}
// Write to the .env file
file_put_contents($envFilePath, $envFile);
$output->writeln("API keys have been written to the .env file");
return Command::SUCCESS;
}
}
+54
View File
@@ -0,0 +1,54 @@
<?php
namespace App\Console\Command;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Dotenv\Dotenv;
class GenerateAppKeyCommand extends Command
{
protected static $defaultName = 'generate:app-key';
protected function configure()
{
$this->setDescription('Generates an application key and writes it to the .env file');
}
protected function execute(InputInterface $input, OutputInterface $output)
{
// Generate random key
$appKey = bin2hex(random_bytes(32)); // Generates a 64-character key (32 bytes)
// Output to terminal
$output->writeln("Generated Key: $appKey");
// Load the .env
$dotenv = new Dotenv();
$envFilePath = __DIR__ . '/../../../.env'; // Adjust the path as needed
if (!file_exists($envFilePath)) {
$output->writeln(".env file not found!");
return Command::FAILURE;
}
// Read the content of the .env file
$envFile = file_get_contents($envFilePath);
// Replace the APP_KEY or add it if it doesn't exist
if (strpos($envFile, 'APP_KEY=') !== false) {
// If a line with APP_KEY already exists, replace it
$envFile = preg_replace('/^APP_KEY=.*$/m', "APP_KEY=$appKey", $envFile);
} else {
// Otherwise, add it at the end
$envFile .= "\nAPP_KEY=$appKey\n";
}
// Write the new content to the .env file
file_put_contents($envFilePath, $envFile);
$output->writeln("The application key has been written to the .env file");
return Command::SUCCESS;
}
}
+85
View File
@@ -0,0 +1,85 @@
<?php
namespace App\Console\Command;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Illuminate\Database\Capsule\Manager as Capsule;
use Symfony\Component\Dotenv\Dotenv;
use Faker\Factory as Faker;
class MigrateCrudExampleCommand extends Command
{
protected static $defaultName = 'migrate:crudexample';
protected function configure()
{
$this->setDescription('Migrates the database by creating the crudexample table and adding fake records for testing.');
}
protected function execute(InputInterface $input, OutputInterface $output)
{
// Load the variables from the .env file
$dotenv = new Dotenv();
$dotenv->load(__DIR__ . '/../../../.env');
$capsule = new Capsule;
$capsule->addConnection([
'driver' => $_ENV['DB_CONNECTION'],
'host' => $_ENV['DB_HOST'],
'database' => $_ENV['DB_DATABASE'],
'username' => $_ENV['DB_USERNAME'],
'password' => $_ENV['DB_PASSWORD'],
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
]);
// Set Capsule as the global Eloquent ORM manager
$capsule->setAsGlobal();
// Boot Eloquent ORM
$capsule->bootEloquent();
// Check if the crudexample table already exists
if (Capsule::schema()->hasTable('crudexample')) {
$output->writeln('The "crudexample" table already exists. No action needed.');
return Command::SUCCESS;
}
// Create the crudexample table
$capsule->schema()->create('crudexample', function ($table) {
$table->increments('id');
$table->string('company', 50);
$table->string('name', 50);
$table->string('password', 255);
$table->string('email', 100)->unique();
$table->string('address', 50);
$table->string('phone', 50);
$table->text('notes')->nullable();
$table->timestamps();
});
// Generate 30 fake records
$faker = Faker::create();
for ($i = 0; $i < 30; $i++) {
Capsule::table('crudexample')->insert([
'company' => $faker->company,
'name' => $faker->name,
'password' => password_hash('password', PASSWORD_BCRYPT), // Default password for testing
'email' => $faker->unique()->safeEmail,
'address' => $faker->address,
'phone' => $faker->phoneNumber,
'notes' => $faker->sentence,
'created_at' => date('Y-m-d H:i:s'),
'updated_at' => date('Y-m-d H:i:s'),
]);
}
$output->writeln('Migration of the "crudexample" table and insertion of fake records for example completed successfully.');
return Command::SUCCESS;
}
}
+23
View File
@@ -0,0 +1,23 @@
<?php
namespace App\Console\Command;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
class SayHelloCommand extends Command
{
// Nome do comando no terminal
protected static $defaultName = 'app:say-hello';
protected function configure(): void
{
$this->setDescription('Exibe uma mensagem de saudação.');
}
protected function execute(InputInterface $input, OutputInterface $output): int
{
$output->writeln('Hello, SysMVC!');
return Command::SUCCESS;
}
}