Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

202
Visualizações
Laravel console command trait method not found

I have a Laravel project that has been deployed with Forge and had OPCache enabled using Forge. I noticed last week that when I pushed some changes, the changes that were in the views and in the controllers were present on the server, but custom artisan commands that I run don't recognize updates.

Put another way, updates to the blades are showing on the screen. Updates that I have added to the controllers are changing the way information is passed to the blade files, but I have a custom artisan command that runs a series of methods in a trait. The actual file on the server shows the new method that I pushed, but when I run the artisan command in the CLI, it says that the method cannot be found.

I have stopped, restarted, and reloaded OPCache countless times. I have restarted Nginx. I have disabled OPCache and restarted PHP. It is still saying that the method is not found. Does anyone have any ideas?

<?php

namespace App\Console\Commands;

use Illuminate\Console\Command;
use App\Traits\FTPImportsTrait;

class CheckFTPImports extends Command
{
   use FTPImportsTrait;

   protected $signature = 'checkForImports';

   protected $description = 'Check for imports...';

    /**
     * Create a new command instance.
     *
     * @return void
     */
    public function __construct()
    {
        parent::__construct();
    }

    /**
     * Execute the console command.
     *
     * @return mixed
     */
    public function handle()
    {
      $this->checkBankImports();
    }
}

-----------

<?php

namespace App\Traits;

trait FTPImportsTrait;
{
   public function checkBankImports()
   {
      dd('YOU ARE NOT CRAZY');
   }
}

$ php artisan checkForImports

$ method checkBankImports does not exist.

UPDATE:

It has to be some sort of configuration issue on the server. I just deployed the project to a fresh DO droplet and the command works as expected.

over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

It only happened in the production environment for me.

Running:

php artisan clear-compiled 

deleted the cached version and solved my issue.

Thanks a ton to @num8er.

over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda