Skip to content

Refactor initializer for web routes file modification #150

Description

@DenTray

Description

What needs to be done?

Refactor the project initializer to modify the existing routes/web.php file by using functionality from the larabuilder (removeRoutes, removeImports , addImports, addRoutes) package instead of recreating the file during project initialization.


Required changes:

  • Update the initializer logic so it works with the existing routes/web.php file.
  • Remove the default route block below by using the removeRoutes method:
Route::get('/', function () {
return view('welcome');
});
  • Remove the import Illuminate\Support\Facades\Route below by using the removeImports method.
  • Add the import Illuminate\Support\Facades\Auth below by using the addImports method.
  • Add the route configuration below by using the addRoutes method:
Auth::routes([
'register' => false,
'reset' => false,
'verify' => false,
]);

Notes:

  • Do not recreate or fully overwrite the routes/web.php file.
  • Keep other existing content in routes/web.php unchanged.

Expected Outcome

What is the expected result?

The project initializer updates the existing routes/web.php file in place.

After initialization:

  • the default welcome route is removed;
  • the Route facade import is removed;
  • the Auth facade import is added;
  • Auth::routes([...]) is added with disabled register, reset, and verify options;
  • all other existing code in routes/web.php stays unchanged.

Verification Scenarios

How can this be tested?

  • Generate a fresh Laravel project.
  • Run the project initialization command.
  • Check that the initializer does not recreate or overwrite routes/web.php.
  • Verify that this route block is removed:
Route::get('/', function () {
return view('welcome');
});
  • Verify that the use Illuminate\Support\Facades\Route import is removed.
  • Verify that the use Illuminate\Support\Facades\Auth import is added.
  • Verify that this code is added:
Auth::routes([
'register' => false,
'reset' => false,
'verify' => false,
]);
  • Verify that other existing routes and imports in routes/web.php are not changed.
  • Run the application and confirm the routes file is valid and loads without syntax errors.
  • Ensure no debug information or errors in the console.

Resources

Materials (Screenshots, Figma Links, References)

Larabuilder: https://github.com/RonasIT/larabuilder/

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions