Reputation: 477
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...
Class is at his place
AttributeFront got right namespace
And even in IDE it paints with a grey font and error like it is unused on page. What can it be????
No, really what the hell is this? It told that class not found and throws me full listing of not-founded class in error!!!
Upvotes: 2
Views: 2898
Reputation: 477
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.
Upvotes: 0
Reputation: 1249
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);
}
}
Upvotes: 1