我有我創建,並作爲bheng
用戶無法打開本地文件,但該文件是有
php /home/forge/site.com/artisan products:exportdiff --env=production
該文件導出到我的/files/product-exports/
目錄
而且執行的PHP的工匠命令,我已經做了
chmod -R 777 files/product-exports/
結果
出口部分工作正常,我得到的文件中導出,你可以在下面
什麼是white
之間的不同和顏色代碼?
爲什麼它放在點.
下?
這是否意味着什麼?
問題
這是一些有權限呢?
如何進一步調試?
我打開此時的任何建議。
任何提示/建議/對此的幫助將非常感謝!
更新
由於從要求@Tensibai
CD /home/forge/site.com/ & & PWD & & PHP /家庭/僞造/網站。COM /手工藝品:exportdiff --env =生產
/home/forge/site.com
.
Export created successfully. Export ID is 1085
Source: /home/forge/site/files/product-exports/export1085_2016-11-23.csv
Destination: /Site/inbound/products/productexport1085_2016-11-23.csv
$source NOT exist !
[Exception]
Could not open local file: /home/forge/site/files/product-exports/export1085_2016-11-23.csv.
products:exportdiff
UPDATE2
$source = /home/forge/site/files/product-exports/export1088_2016-11-23.csv
我已經試過dd(file_exists($source));
它不停地回報bool(false)
是因爲我檢查file_exists的方式嗎?
UPDATE3
這裏是我的ExportProductsDiff.php
<?php
use Illuminate\Console\Command;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\InputArgument;
class ExportProductsDiff extends Command {
/**
* The console command name.
*
* @var string
*/
protected $name = 'products:exportdiff';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Export all products to Diff.';
/**
* The system export message.
*
* @var string
*/
protected $system_message = '[System Diff Export]';
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}
/**
* Execute the console command.
*
* @return mixed
*/
public function fire()
{
// Export the products by calling the ExportProducts Command
$options = [
'--format' => "distributor",
'--encoding' => "standard csv",
'--categories' => "all categories",
'--conjugate' => 1,
'--include_disabled'=> 1,
'--export_notes' => $this->system_message
];
// Run the export
$this->call('products:export', $options);
$last_run_export = ProductExport::where('notes', '=', $this->system_message)
->where('status', '=', 'finished')
->where('format', '=', 'distributor')
->orderBy('id', 'desc')
->firstOrFail();
$this->info('Export created successfully. Export ID is ' . $last_run_export->id);
$env = $this->option('env');
if ($env == 'production'){
$localdomain = '*******';
}else{
$env = 'development';
$localdomain = '*******';
}
$sftp_server = '*******';
$sftp_user_name = '*******';
$sftp_user_pass = '*******';
// Open the SFTP connection
$connection = @ssh2_connect($sftp_server);
if (!$connection)
{
throw new Exception("Could not connect to $sftp_server.");
}
// Login to the SFTP server
if (! @ssh2_auth_password($connection, $sftp_user_name, $sftp_user_pass))
{
throw new Exception("Could not authenticate with username $sftp_user_name " .
"and password $sftp_user_pass.");
}
$sftp = @ssh2_sftp($connection);
if (!$sftp)
{
throw new Exception("Could not initialize SFTP subsystem.");
}
// Prepare the files
$source = '/home/forge/site/files/product-exports/' . $last_run_export->file_name;
/////////////////////////////////////
//The bug is here
// update site to site.com
/////////////////////////////////////
$destination = '/Site/inbound/products/product' . $last_run_export->file_name;
$this->info('Source: ' . $source);
$this->info('Destination: ' . $destination);
if (!file_exists('/Site/inbound/products/')) {
ssh2_sftp_mkdir($sftp, '/Site/inbound/products/', 0775, true);
}
dd(file_exists($source));
if (file_exists($source)) {
chmod($source, 0775);
}else{
$this->info('$source NOT exist !');
}
// Upload the file
$stream = @fopen("ssh2.sftp://$sftp$destination", 'w');
if (!$stream)
{
throw new Exception("Could not open file: $destination");
}
$data_to_send = @file_get_contents($source);
if ($data_to_send === false)
{
throw new Exception("Could not open local file: $source.");
}
if (@fwrite($stream, $data_to_send) === false)
{
throw new Exception("Could not send data from file: $source.");
}
@fclose($stream);
// Delete the export when finished
if (file_exists(base_path() . ProductExport::path . $last_run_export->file_name))
{
unlink(base_path() . ProductExport::path . $last_run_export->file_name);
}
$last_run_export->delete();
}
/**
* Get the console command arguments.
*
* @return array
*/
protected function getArguments()
{
return array();
}
/**
* Get the console command options.
*
* @return array
*/
protected function getOptions()
{
return array();
}
}
如您所見,您的文件名以點號 –
結尾,根據屏幕截圖顯示的文件列表不符合。我在想和你一樣的事情。 – ihue
O_o ....你在運行什麼系統? 'pwd'不應該返回'.' ... – Tensibai