Luis
Luis

Reputation: 2143

Laravel and Eclipse: How to avoid errors in default code of Laravel 5.5?

I have created a new project in Laravel and I have opened it with the Eclipse IDE (for PHP), but I get an error in the default code generated by Laravel for the routes. How can I prevent this from happening?

enter image description here

I have only created the project and I have opened it with Eclipse and I have that error.

Upvotes: 4

Views: 4631

Answers (3)

Szymon Dziewanowski
Szymon Dziewanowski

Reputation: 357

put

namespace Illuminate\Support\Facades;

at the top of the file

Upvotes: -2

Kronzeuge
Kronzeuge

Reputation: 31

I'm new to Eclipse and just ran into the same problem and solved it by creating a library. My Eclipse version is 2018-09 (4.9.0).

  1. Firstly, require the barryvdh/laravel-ide-helper package with composer using the following command:

    composer require barryvdh/laravel-ide-helper
    
  2. Afterwards generate the _ide_helper.php with Artisan:

    php artisan ide-helper:generate
    
  3. Copy the generated file into a directory outside of your workspace

  4. In Eclipse switch to "Window/Preferences" and the select "PHP/Libraries"
  5. Create a new library with "New..."
  6. After creating it click on "Edit..." and check the checkbox "environment (added to the script environment"
  7. Add the folder now to your library over "Add External Folder..."

Once the library is created you may need to delete all the entries in the "Problems" View and validate the project again.

Upvotes: 3

user320487
user320487

Reputation:

Import the Route facade at the top of the file like Request.

use Illuminate\Support\Facades\Route;

I recommend using this package, barrydvh/ide-helper, in your projects. It generates a mapping of Laravel's facades and other static methods that the IDE has trouble with out of the box.

You'll need to install Eclipse PHP plugin (PDT), as well.

Once you have everything setup, run:

php artisan ide-helper:generate

and refresh the project.

Upvotes: 4

Related Questions