2
votes

Ok, i've got some voodoo magic here. inb4 - I've made composer dump and dump-autoload 100 000 times.

<?
namespace Cds\Goods\Classes;

use Cds\Goods\Classes\Logs;
use Cds\Goods\Classes\AttributeUniteFront;

class ShiptorSync extends Shiptor{

    public static function sync_products() {    
        Logs::add_to_log("shiptor_sync", date("d.m.Y"), "begin sync shiptor products");
        $name = AttributeUniteFront::getSlugProduct($item->cds_products_id);
    }
}

Here is my class which function sync_products() I'm calling in console command, like that

<?php
​
namespace App\Console\Commands;
​
use Cds\Goods\Classes\ShiptorSync;
use Illuminate\Console\Command;
​
/**
 * Class ShiptorSynchronizeProducts
 */
class ShiptorSynchronizeProducts extends Command
{
  /**
   * The name and signature of the console command.
   *
   * @var string
   */
  protected $signature = 'shiptor:products:synchronize';
​
  /**
   * The console command description.
   *
   * @var string
   */
  protected $description = 'Sync goods';
​
  /**
   * Execute the console command.
   */
  public function handle()
  {
    ShiptorSync::sync_products();
  }
}

And everytime when i run it from console - Class 'Cds\Goods\Classes\AttributeUniteFront' not found

But! Class Logs found succesfully. What the heck...

enter image description here

Class is at his place

AttributeFront got right namespace enter image description here

And even in IDE it paints with a grey font and error like it is unused on page. What can it be????

enter image description here

enter image description here

No, really what the hell is this? It told that class not found and throws me full listing of not-founded class in error!!!

enter image description here

2
first line of question - did it 100 000 timesEvgeny Malkov
Cds\Goods\Classes\AttributeUniteFront is this class place in vendor?J. Doe
It is in OctoberCMS plugin in folder /var/www/site.test/web/plugins/cds/goods/classesEvgeny Malkov
near class Logs loads perfectlyEvgeny Malkov
can you post composer.json where this namespace registered?J. Doe

2 Answers

1
votes

Add to command controller:

 public function __construct()
    {
        parent::__construct();
    }

In Kernel.php:

protected $commands = [
        //
        '\App\Console\Commands\ShiptorSynchronizeProducts',
    ];

Then, why not just handle() the sync_products in the command? Also, $item does not appear to be defined.

Add this to the command file:

    use Cds\Goods\Classes\Logs;
    use Cds\Goods\Classes\AttributeUniteFront;

public function handle()
  {
    Logs::add_to_log("shiptor_sync", date("d.m.Y"), "begin sync shiptor products");
        $name = AttributeUniteFront::getSlugProduct($item->cds_products_id);
  }
}
0
votes

Gosh, i dunno why but the case was in opening short PHP tag, although short_open_tag is enabled. However i change it and everything works.