1. Go to this page and download the library: Download rnr1721/codecraft library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
use rnr1721\CodeCraft\CodeCraftFactory;
use rnr1721\CodeCraft\AdapterRegistry;
use rnr1721\CodeCraft\Adapters\PhpAdapter;
// Using factory for easier setup
$registry = new AdapterRegistry();
$registry->register(new PhpAdapter());
$factory = new CodeCraftFactory($registry);
$codecraft = $factory->create();
// Or create with no adapters
$emptyCodecraft = $factory->createEmpty();
// Check support
$canHandle = $codecraft->supports('php');
$extensions = $codecraft->getSupportedExtensions();
// Get help for specific file type
$help = $codecraft->getHelp('php');
// Simple path-based operations that AI can easily understand
$codecraft->write('app/Models/Post.php', [
'namespace' => 'App\\Models',
'name' => 'Post',
'extends' => 'Model'
]);
// Get help for any file type
$help = $codecraft->getHelp('jsx');
// Check what's supported
$extensions = $codecraft->getSupportedExtensions();
// Validate before creating
if ($codecraft->supports('py')) {
$codecraft->write('app/services/user_service.py', $options);
}
use rnr1721\CodeCraft\Interfaces\FileAdapterInterface;
class RustAdapter implements FileAdapterInterface
{
public function getName(): string
{
return 'rust';
}
public function getSupportedExtensions(): array
{
return ['rs'];
}
public function create(string $filePath, array $options = []): string
{
// Implementation for creating Rust files
}
public function edit(string $filePath, array $modifications): string
{
// Implementation for editing Rust files
}
public function analyze(string $filePath): array
{
// Implementation for analyzing Rust files
}
public function validate(string $content): bool
{
// Implementation for validating Rust syntax
}
public function getCapabilities(): array
{
return [
'create_struct' => true,
'create_trait' => true,
'create_enum' => true
];
}
public function getVersion(): string
{
return '1.0.0';
}
public function getHelp(): array
{
return [
'description' => 'Rust adapter for structs, traits, and enums',
'supported_types' => [
'struct' => 'Create Rust structs',
'trait' => 'Create Rust traits',
'enum' => 'Create Rust enums'
],
'examples' => [
// ... comprehensive examples
],
'options' => [
// ... available options
]
];
}
}
// Register your adapter
$codecraft->registerAdapter(new RustAdapter());
// In an Artisan command
use rnr1721\CodeCraft\Interfaces\CodeCraftInterface;
class MakeAdvancedModelCommand extends Command
{
protected $signature = 'make:advanced-model {name}';
public function handle(CodeCraftInterface $codecraft)
{
$name = $this->argument('name');
$path = "app/Models/{$name}.php";
$success = $codecraft->write($path, [
'namespace' => 'App\\Models',
'name' => $name,
'extends' => 'Model',
'properties' => [
['name' => 'fillable', 'visibility' => 'protected', 'type' => 'array']
]
]);
if ($success) {
$this->info("Model {$name} created successfully!");
}
}
}
// In any Laravel class (Controller, Service, etc.)
use rnr1721\CodeCraft\Interfaces\CodeCraftInterface;
class CodeGeneratorService
{
public function __construct(
private CodeCraftInterface $codecraft
) {}
public function generateUserModel(): bool
{
return $this->codecraft->write('app/Models/User.php', [
'namespace' => 'App\\Models',
'name' => 'User',
'extends' => 'Model'
]);
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.