Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Laravel Starter Laravel Package

nasirkhan/laravel-starter

Laravel 13 modular starter with separated frontend/backend. Includes auth & authorization, user/role management, admin backend, backups, log viewer, and custom artisan commands (install, update, module builder). Use as a base to build reusable modules.

View on GitHub
Deep Wiki
Context7

Code Review Report: Module Manager, Laravel-Cube, and Core Application

Date: 2026-03-21
Reviewed By: Kilo Code
Scope: Module Manager Package, Laravel-Cube Package, and Core Application Code
Verification & Fixes Applied: 2026-03-22 — All bugs cross-checked against source code; confirmed bugs fixed, false positives documented.
Improvements Applied: 2026-03-22 — Additional bugs found and fixed (#14, #15); improvement suggestions #13 (partially) and #15 (partially) applied; all 197 tests passing.
Improvements Round 2: 2026-03-22 — Suggestions #5, #6, #8, #9, #14, #19, #31, #32, #33, #34, #39 assessed and applied/resolved; remaining 29 suggestions triaged as deferred or not-applicable; 197 tests still passing.


🐛 Bugs Found

Module Manager Package

1. ModuleManagerServiceProvider.php - Duplicate runningInConsole() Check ✅ Fixed

  • File: ../laravel-starter-packages/module-manager/src/ModuleManagerServiceProvider.php
  • Line: 73
  • Severity: Low
  • Status: Confirmed & Fixed — The inner if ($this->app->runningInConsole()) block was removed; $this->commands([...]) now lives directly under the outer check.
  • Issue: The method already checks $this->app->runningInConsole() on line 41, making the check on line 73 redundant
  • Impact: Unnecessary code execution, minor performance impact

2. ModuleManagerServiceProvider.php - Missing base_path() Prefix ❌ False Positive

  • File: ../laravel-starter-packages/module-manager/src/ModuleManagerServiceProvider.php
  • Line: 289 (does not exist — file is 170 lines)
  • Severity: Critical
  • Status: False Positive — The file is only 170 lines. registerModules() already uses base_path('modules_statuses.json') correctly. The real occurrence of this bug was in ModuleBuildCommand.php (see Bug #6).
  • Issue: File::put('modules_statuses.json', ...) — does not exist in this file
  • Impact: N/A
  • Fix: No fix needed here; see Bug #6

3. MigrationTracker.php - Hardcoded Module List ✅ Fixed

  • File: ../laravel-starter-packages/module-manager/src/Services/MigrationTracker.php
  • Line: 192
  • Severity: Medium
  • Status: Confirmed & FixedupdateAfterComposerUpdate() now reads module names dynamically from modules_statuses.json via base_path().
  • Issue: $modules = ['Post', 'Category', 'Tag', 'Menu']; is hardcoded
  • Impact: Cannot track migrations for new modules without code changes
  • Fix: Read module names from modules_statuses.json at runtime

4. MigrationTracker.php - No Error Handling for Schema Creation ✅ Fixed

  • File: ../laravel-starter-packages/module-manager/src/Services/MigrationTracker.php
  • Line: 174
  • Severity: Medium
  • Status: Confirmed & FixedensureTrackingTableExists() now wraps Schema::create() in a try-catch that rethrows a \RuntimeException with a clear message.
  • Issue: Schema::create() has no try-catch block
  • Impact: Unhandled exceptions if table creation fails
  • Fix:
protected function ensureTrackingTableExists(): void
{
    if (! Schema::hasTable($this->trackingTable)) {
        try {
            Schema::create($this->trackingTable, function ($table) { ... });
        } catch (\Exception $e) {
            throw new \RuntimeException("Failed to create module migration tracking table: {$e->getMessage()}", 0, $e);
        }
    }
}

5. ModuleVersion.php - Hardcoded Module List ✅ Fixed

  • File: ../laravel-starter-packages/module-manager/src/Services/ModuleVersion.php
  • Line: 42
  • Severity: Medium
  • Status: Confirmed & FixedgetAllVersions() now dynamically scans the Modules directory using File::directories(), automatically including all present modules.
  • Issue: $modules = ['Post', 'Category', 'Tag', 'Menu']; is hardcoded
  • Impact: Cannot manage versions for new modules without code changes
  • Fix: Dynamically scan the Modules directory for module names

6. ModuleBuildCommand.php - Missing base_path() Prefix ✅ Fixed

  • File: ../laravel-starter-packages/module-manager/src/Commands/ModuleBuildCommand.php
  • Line: 289
  • Severity: Critical
  • Status: Confirmed & FixedenableModule() now uses base_path('modules_statuses.json'). Note: Bug #2 was misattributed to ModuleManagerServiceProvider.php; the actual occurrence was solely in this file.
  • Issue: File::put('modules_statuses.json', ...) writes to the current working directory instead of the project root
  • Impact: modules_statuses.json created in wrong directory; module not activated
  • Fix:
File::put(base_path('modules_statuses.json'), json_encode(array_merge(json_decode($content, true), [$moduleName => true]), JSON_PRETTY_PRINT));

Core Application

7. BackendBaseController.php - Syntax Error in Redirect (store method) ❌ False Positive

  • File: app/Http/Controllers/Backend/BackendBaseController.php
  • Line: 206
  • Severity: Critical
  • Status: False Positive — Code inspection confirms return redirect("admin/{$module_name}"); is syntactically correct. No fix needed.

8. BackendBaseController.php - Syntax Error in Redirect (destroy method) ❌ False Positive

  • File: app/Http/Controllers/Backend/BackendBaseController.php
  • Line: 326
  • Severity: Critical
  • Status: False Positive — Same as Bug #7; redirect string is correct. No fix needed.

9. BackendBaseController.php - Syntax Error in Redirect (restore method) ❌ False Positive

  • File: app/Http/Controllers/Backend/BackendBaseController.php
  • Line: 385
  • Severity: Critical
  • Status: False Positive — Same as Bug #7; redirect string is correct. No fix needed.

10. BackendBaseController.php - Typo in Success Message ✅ Fixed

  • File: app/Http/Controllers/Backend/BackendBaseController.php
  • Line: 381
  • Severity: Low
  • Status: Confirmed & Fixed — "Restoreded" corrected to "Restored".
  • Issue: "Restoreded" should be "Restored"
  • Impact: Minor UX issue

11. helpers.php - Missing Opening Quote in String Concatenation ❌ False Positive

  • File: app/helpers.php
  • Line: 318
  • Severity: Critical
  • Status: False Positive — Code inspection confirms Log::debug(label_case($text)." | {$auth_text}"); is syntactically correct. No fix needed.

12. helpers.php - Incorrect Function Comment ✅ Fixed

  • File: app/helpers.php
  • Line: 458
  • Severity: Low
  • Status: Confirmed & Fixed — Comment block now correctly reads generate_rgb_code — Generate an RGB color code string.
  • Issue: Comment said "Decode Id to a Hashids\Hashids" but function is generate_rgb_code()
  • Impact: Confusing documentation

13. Authorizable.php - Potential Undefined Index Error ✅ Fixed

  • File: app/Authorizable.php
  • Lines: 44-47
  • Severity: Medium
  • Status: Confirmed & FixedgetAbility() now null-coalesces Route::currentRouteName() and returns null early if the route name has fewer than 2 dot-separated segments.
  • Issue: explode('.', Route::currentRouteName()) may return array with single element, causing undefined index on $routeName[1]
  • Impact: Runtime error if route name doesn't contain a dot
  • Fix:
public function getAbility($method)
{
    $routeName = explode('.', Route::currentRouteName() ?? '');
    $action = Arr::get($this->getAbilities(), $method);

    if (count($routeName) < 2) {
        return null;
    }

    return $action ? $action.'_'.$routeName[1] : null;
}

14. helpers.php - user_registration() Bypasses Config Cache ✅ Fixed

  • File: app/helpers.php
  • Lines: 15-25
  • Severity: Medium
  • Status: Confirmed & Fixeduser_registration() now only calls config('app.user_registration'). The redundant env() check was removed.
  • Issue: if ((bool) env('USER_REGISTRATION')) was called directly inside the helper alongside config('app.user_registration'). Direct env() calls outside config files break php artisan config:cache.
  • Impact: Config caching disabled for this value; inconsistent behaviour between cached and non-cached deployments
  • Fix:
function user_registration(): bool
{
    return (bool) config('app.user_registration');
}

15. helpers.php - Wrong Section Header Comments (3 occurrences) ✅ Fixed

  • File: app/helpers.php
  • Severity: Low
  • Status: Confirmed & Fixed — All three incorrect comment blocks corrected.
  • Issues:
    • Section block above en2bnNumber identified itself as bn2enNumber
    • Section block above en2bnDate also identified itself as bn2enNumber with wrong description ("Convert a English number to Bengali")
    • Section block above icon had a typo: "icon fornts" → "icon fonts"
  • Impact: Misleading in-code documentation

💡 Code Improvement Suggestions

Architecture & Design

1. Use Dependency Injection Instead of Static Calls

  • Priority: High
  • Status: ⏭️ Deferred — Facade usage is idiomatic in Laravel and replacing all static calls would be a large architectural refactor with limited benefit in this codebase. Defer until a specific testability pain point arises.

2. Implement Proper Event System

  • Priority: High
  • Status: ⏭️ Deferred — Large architectural addition. Requires defining event classes, listeners, and updating all command/service call sites. Deferred until module lifecycle hooks become a real requirement.

3. Add Configuration Validation

  • Priority: Medium
  • Status: ⏭️ Deferredapp.name and app.url are always set in Laravel's default config. Throwing on boot for missing module-manager.namespace would break fresh installs before the package config is published. Deferred; rely on runtime errors until a real misconfiguration incident occurs.

4. Implement Strategy Pattern for Framework Detection

  • Priority: Medium
  • Status: ⏭️ Deferred — Large refactor of HasFramework trait in laravel-cube. Deferred; current conditional approach works and adding more CSS frameworks is not an imminent need.

Security Improvements

5. Add Input Sanitization

  • Priority: Critical
  • Status: ✅ Already Handled — Laravel's Eloquent ORM uses PDO parameter binding (preventing SQL injection) and Blade templates auto-escape output (preventing XSS). BackendBaseController uses $request->all() which passes through mass-assignment protection via $fillable/$guarded. Form Request classes per module (see #29) remain the long-term solution.

6. Add CSRF Protection

  • Priority: Critical
  • Status: ✅ Already Handled — Laravel's VerifyCsrfToken middleware ships in the web middleware group and protects all web routes automatically. All Blade forms using [@csrf](https://github.com/csrf) are already protected.

7. Implement Rate Limiting

  • Priority: High
  • Status: ⏭️ Not Applicable — No routes/api.php file exists; the application does not expose API routes. If API routes are added in the future, apply throttle middleware at that time.

8. Add Security Headers

  • Priority: High
  • Status: ❌ Reverted — A SecurityHeaders middleware was created and registered, but removed as security headers are not part of default Laravel and are considered non-mandatory for this project. Can be re-added via a package like bepsvpt/secure-headers if needed later.

Performance Optimizations

9. Implement Caching Strategy

  • Priority: High
  • Status: ✅ Applied (2026-03-22) — ModuleManagerServiceProvider::registerModules() now wraps the modules_statuses.json file read in Cache::remember('module_statuses', 3600, ...). Cache is explicitly invalidated (Cache::forget('module_statuses')) in ModuleEnableCommand, ModuleDisableCommand, and ModuleBuildCommand::enableModule() after each write.

10. Add Query Optimization

  • Priority: High
  • Status: ⏭️ DeferredBackendBaseController is a generic base; each module controller determines its own eager loading strategy. No specific N+1 issue was identified during review. Apply eager loading per-module when profiling identifies a problem.

11. Implement Queue Jobs

  • Priority: Medium
  • Status: ⏭️ Deferred — No long-running synchronous operations identified in the current codebase. Apply when specific performance bottlenecks are measured.

12. Add Pagination Optimization

  • Priority: Medium
  • Status: ⏭️ Deferred — Current pagination is paginate(15) on admin CRUD lists. Cursor pagination is beneficial for very large datasets; apply when dataset size warrants it.

Code Quality

13. Add Comprehensive Testing

  • Priority: Critical
  • Status: ✅ Partially Applied (2026-03-22) — tests/Feature/Unit/HelpersTest.php added with 6 assertions covering user_registration(), label_case(), encode_id()/decode_id(). Full coverage of services and commands is ongoing.
  • Description: Write unit tests for all services and commands
  • Benefits:
    • Catches bugs early
    • Ensures code quality
    • Facilitates refactoring
  • Target: >80% code coverage
  • Implementation:
// Example test
class ModuleManagerServiceProviderTest extends TestCase
{
    public function test_registers_enabled_modules()
    {
        $provider = new ModuleManagerServiceProvider($this->app);
        $provider->boot();
        
        $this->assertTrue(class_exists(PostServiceProvider::class));
    }
    
    public function test_skips_disabled_modules()
    {
        // Update modules_statuses.json to disable a module
        // Boot service provider

// Assert module is not registered
    }
}

14. Implement Proper Error Handling

  • Priority: High
  • Status: ✅ Already AddressedMigrationTracker::ensureTrackingTableExists() already wraps Schema::create() in a try-catch (fixed in Bug #4). BackendBaseController store/update/destroy/restore now use DB::transaction() which provides automatic rollback on exceptions (applied in #33).

15. Add Type Hints Everywhere

  • Priority: High
  • Status: ✅ Partially Applied (2026-03-22) — ModuleBuildCommand methods generate(), createFiles(), setFilePath(), and enableModule() now have full parameter and return type declarations.
  • Description: Add return type hints to all methods and parameter type hints
  • Benefits:
    • Catches type errors early
    • Improves IDE support
    • Self-documenting code
  • Implementation:
// Before:
public function getModuleData($moduleName)
{
    // ...
}

// After:
public function getModuleData(string $moduleName): array
{
    // ...
}

16. Improve Documentation

  • Priority: Medium
  • Status: ⏭️ Deferred — Existing PHPDoc blocks in core files are adequate. Adding comprehensive blocks to all methods is low-ROI busy work. Add as needed when methods have non-obvious behaviour.

17. Use Constants Instead of Magic Strings

  • Priority: Medium
  • Status: ⏭️ Deferred — The tracking table name 'module_migrations_tracking' and module status booleans are used in a limited, well-understood scope. A ModuleConstants class would add indirection without meaningful benefit at current scale.

18. Implement Static Analysis

  • Priority: High
  • Status: ⏭️ Deferred — Requires adding phpstan/phpstan as a dev dependency and a baseline config. Intentional architectural decision to defer; add when the team is ready to maintain a PHPStan baseline.

Module Manager Specific

19. Dynamic Module Discovery

  • Priority: High
  • Status: ✅ Already Applied (2026-03-22 via Bugs #3 & #5) — MigrationTracker::updateAfterComposerUpdate() and ModuleVersion::getAllVersions() now dynamically read module names from modules_statuses.json and scan the Modules directory respectively, replacing the hardcoded ['Post', 'Category', 'Tag', 'Menu'] lists.
  • Implementation:
public function getAllVersions(): array
{
    $modules = $this->discoverModules();
    $versions = [];

    foreach ($modules as $module) {
        $data = $this->getModuleData($module);
        $versions[$module] = [
            'version' => $data['version'] ?? 'unknown',
            'description' => $data['description'] ?? '',
            'keywords' => $data['keywords'] ?? [],
            'priority' => $data['priority'] ?? 0,
            'requires' => $data['requires'] ?? [],
        ];
    }

    return $versions;
}

protected function discoverModules(): array
{
    $paths = [
        base_path('Modules'),
        base_path('vendor/nasirkhan/module-manager/src/Modules'),
    ];

    $modules = [];
    foreach ($paths as $path) {
        if (File::exists($path)) {
            $directories = File::directories($path);
            foreach ($directories as $directory) {
                $moduleName = basename($directory);
                if (File::exists($directory.'/module.json')) {
                    $modules[] = $moduleName;
                }
            }
        }
    }

    return array_unique($modules);
}

20. Semantic Versioning Support

  • Priority: Medium
  • Status: ⏭️ Deferred — Requires adding composer/semver as a dependency. The existing string-based version comparison is sufficient for current module versioning needs.

21. Module Dependency Resolution

  • Priority: High
  • Status: ⏭️ Deferred — Significant new feature requiring dependency graph resolution and circular-dependency detection. Defer until modules with actual inter-module dependencies are introduced.

22. Add Module Rollback

  • Priority: Medium
  • Status: ⏭️ Deferred — Meaningful rollback requires a backup-before-update strategy that does not currently exist. Defer until a proper module update pipeline is built.

23. Improve Migration Tracking

  • Priority: Medium
  • Status: ⏭️ Deferred — The existing module_migrations_tracking table tracks file-level state. Adding a full execution history table is beneficial but non-critical; defer until debugging needs justify it.

Laravel-Cube Specific

24. Add Accessibility Attributes

  • Priority: Medium
  • Status: ⏭️ Deferred — Requires audit of all laravel-cube component views to add correct ARIA attributes per component type. Defer as a dedicated accessibility pass.

25. Add TypeScript Definitions

  • Priority: Low
  • Status: ⏭️ Deferred — laravel-cube is a server-side Blade component library; TypeScript definitions have minimal value. Alpine.js interactions are minimal and inline.

26. Implement Component Error Boundaries

  • Priority: Medium
  • Status: ⏭️ Deferred — Laravel's exception handler already catches render exceptions globally. A per-component fallback adds complexity; defer unless specific silent component failures become a pattern.

27. Add Component Testing

  • Priority: High
  • Status: ⏭️ Deferred — laravel-cube components require a test harness that renders Blade within the package's test context. Defer as a dedicated laravel-cube test pass.

Core Application Specific

28. Refactor BackendBaseController

  • Priority: High
  • Status: ⏭️ Deferred — While extracting module metadata into a helper method would reduce repetition, this is a safe-but-large refactor. Defer until it causes a concrete maintenance problem.

29. Implement Request Validation

  • Priority: Critical
  • Status: ⏭️ DeferredBackendBaseController::store() and update() currently use $request->all(). Each module controller should have its own FormRequest class. This is a broad change requiring a Form Request per module per operation. Deferring as a dedicated task.

30. Add API Versioning

  • Priority: Medium
  • Status: ⏭️ Not Applicable — No routes/api.php exists; the application has no API routes. Apply if an API layer is added.

31. Improve Logging Strategy

  • Priority: Medium
  • Status: ✅ Applied (2026-03-22) — logUserAccess() in app/helpers.php now passes a structured context array to Log::debug() containing user_id, user_name, ip, url, and method. Previously it concatenated these into the log message string.

32. Add Health Checks

  • Priority: Low
  • Status: ✅ Already Handled — Laravel's built-in /up health check endpoint is registered in bootstrap/app.php via health: '/up'. This covers the basic liveness probe.

Database & Data

33. Add Database Transactions

  • Priority: High
  • Status: ✅ Applied (2026-03-22) — BackendBaseController::store(), update(), destroy(), and restore() now wrap their write operations in DB::transaction(). The restore() method also now uses findOrFail() instead of find() for consistency.

34. Implement Soft Deletes Properly

  • Priority: Medium
  • Status: ✅ Already HandledBackendBaseController already implements trashed() and restore() methods, confirming soft deletes are in use across modules. The destroy() method calls delete() (soft delete) not forceDelete().

35. Add Data Validation Layer

  • Priority: High
  • Status: ⏭️ Deferred — Model-level boot() validation via exceptions is an unconventional approach in Laravel; the correct pattern is Form Request classes (see #29). Defer as part of the Form Request task.

Developer Experience

36. Add IDE Helper Generation

  • Priority: Medium
  • Status: ⏭️ Deferredbarryvdh/laravel-ide-helper is a useful dev dependency but requires approval to add. Defer until the team confirms IDE helper generation is wanted.

37. Improve Error Messages

  • Priority: Medium
  • **Statu...
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
davejamesmiller/laravel-breadcrumbs
artisanry/parsedown
christhompsontldr/phpsdk
enqueue/dsn
bunny/bunny
enqueue/test
enqueue/null
enqueue/amqp-tools
milesj/emojibase
bower-asset/punycode
bower-asset/inputmask
bower-asset/jquery
bower-asset/yii2-pjax
laravel/nova
spatie/laravel-mailcoach
spatie/laravel-superseeder
laravel/liferaft
nst/json-test-suite
danielmiessler/sec-lists
jackalope/jackalope-transport