hussainabuhajjaj/codebot
最新稳定版本:v1.1.0
Composer 安装命令:
composer require hussainabuhajjaj/codebot
包简介
AI-powered Laravel component generator
README 文档
README
# Codebot Laravel Package Codebot is a Laravel package that uses **DeepSeek AI** to generate **migrations**, **models**, and **views** with designs using popular frameworks like **Bootstrap** and **Tailwind CSS**. It simplifies the process of scaffolding Laravel applications by automating repetitive tasks. ## Features - Generate **migrations** with fields and relationships. - Generate **models** with fillable attributes and relationships. - Generate **views** with **Bootstrap** or **Tailwind CSS** designs. - Interactive command-line interface for easy usage. - Customizable templates for migrations, models, and views. --- ## Installation 1. Install the package via Composer: ```bash composer require hussainabuhajjaj/codebot-laravel
-
Publish the configuration file (optional):
php artisan vendor:publish --provider="Hussainabuhajjaj\Codebot\CodebotServiceProvider" --tag="config"
-
Set your DeepSeek API key in the
.envfile:DEEPSEEK_API_KEY=your-api-key-here
Usage
Run the following command to generate code interactively:
php artisan codebot:generate
Example Workflow
-
Generate a Migration:
- Enter the table name (e.g.,
users). - Add fields (e.g.,
name:string,email:string,password:string). - Add relationships (e.g.,
hasMany:posts).
- Enter the table name (e.g.,
-
Generate a Model:
- The model will be created with fillable attributes and relationships.
-
Generate Views:
- Choose a design framework (e.g., Bootstrap or Tailwind CSS).
- Views will be generated for listing, creating, and editing records.
Examples
Example 1: Generate a users Table
-
Run the command:
php artisan codebot:generate
-
Follow the prompts:
- Table name:
users - Fields:
name:stringemail:stringpassword:string
- Relationships:
hasMany:posts - Design framework:
bootstrap
- Table name:
-
Results:
- A migration file is created:
Schema::create('users', function (Blueprint $table) { $table->id(); $table->string('name'); $table->string('email')->unique(); $table->string('password'); $table->timestamps(); });
- A model file is created:
class User extends Model { protected $fillable = ['name', 'email', 'password']; public function posts() { return $this->hasMany(Post::class); } }
- Views are created with Bootstrap styling:
resources/views/users/index.blade.phpresources/views/users/create.blade.phpresources/views/users/edit.blade.php
- A migration file is created:
Example 2: Generate a posts Table
-
Run the command:
php artisan codebot:generate
-
Follow the prompts:
- Table name:
posts - Fields:
title:stringcontent:textuser_id:integer
- Relationships:
belongsTo:user - Design framework:
tailwind
- Table name:
-
Results:
- A migration file is created:
Schema::create('posts', function (Blueprint $table) { $table->id(); $table->string('title'); $table->text('content'); $table->foreignId('user_id')->constrained(); $table->timestamps(); });
- A model file is created:
class Post extends Model { protected $fillable = ['title', 'content', 'user_id']; public function user() { return $this->belongsTo(User::class); } }
- Views are created with Tailwind CSS styling:
resources/views/posts/index.blade.phpresources/views/posts/create.blade.phpresources/views/posts/edit.blade.php
- A migration file is created:
Results
After running the codebot:generate command, you’ll have the following files:
-
Migrations:
- Located in
database/migrations. - Ready to be applied using
php artisan migrate.
- Located in
-
Models:
- Located in
app/Models. - Includes fillable attributes and relationships.
- Located in
-
Views:
- Located in
resources/views. - Styled with Bootstrap or Tailwind CSS.
- Located in
-
Routes:
- Add routes in
routes/web.phpto access the generated views:Route::resource('users', UserController::class); Route::resource('posts', PostController::class);
- Add routes in
Contributing
Contributions are welcome! Here’s how you can contribute:
- Fork the repository.
- Create a new branch:
git checkout -b feature/your-feature-name
- Commit your changes:
git commit -m "Add your feature" - Push to the branch:
git push origin feature/your-feature-name
- Open a pull request.
License
This package is open-source software licensed under the MIT License.
Support
If you encounter any issues or have questions, please open an issue on GitHub.
Enjoy using Codebot! 🚀
统计信息
- 总下载量: 3
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-01-25