我无法运行PHP Artisan Server

时间:2018-10-06 16:39:13

标签: php laravel

我试图在本地计算机上运行我的公共站点。

这是在Laravel 5中完成的。

我收到以下错误:

  

chdir错误():没有这样的文件或目录(错误号2)

我做了我在这篇文章中看到的:

laravel5: chdir(): No such file or directory (errno 2)

我再次运行PHP Artisan服务器,但是现在它向我显示了这一点:

  

警告:require_once(C:\ Users \ wacks \ Desktop \ TEC \ webtec / public / index.php):无法打开流:C:\ Users \ wacks \ Desktop \ TEC \ webtec中没有此类文件或目录\ server.php在第21行

     

严重错误:require_once():无法在C中打开所需的'C:\ Users \ wacks \ Desktop \ TEC \ webtec / public / index.php'(include_path ='C:\ xampp_1 \ php \ PEAR') \第21行的\ Users \ wacks \ Desktop \ TEC \ webtec \ server.php

这是我的代码:

serve.php      

 namespace App\Console\Commands;

 use Exception;
 use Illuminate\Console\Command;
 use Symfony\Component\Console\Input\InputOption;
 use Symfony\Component\Process\PhpExecutableFinder;
 use Symfony\Component\Process\ProcessUtils;

 class Serve extends Command {
/**
 * The console command name.
 *
 * @var string
 */
protected $name = 'serve';

/**
 * The console command description.
 *
 * @var string
 */
protected $description = 'Serve the application on the PHP development server';

/**
 * Execute the console command.
 *
 * @return void
 *
 * @throws \Exception
 */
public function fire() {
    chdir('/');

    $host = $this->input->getOption('host');

    $port = $this->input->getOption('port');

    $base = ProcessUtils::escapeArgument($this->laravel->basePath());

    $binary = ProcessUtils::escapeArgument((new PhpExecutableFinder)->find(false));

    $this->info("Laravel development server started on http://{$host}:{$port}/");

    if (defined('HHVM_VERSION')) {
        if (version_compare(HHVM_VERSION, '3.8.0') >= 0) {
            passthru("{$binary} -m server -v Server.Type=proxygen -v Server.SourceRoot={$base}/ -v Server.IP={$host} -v Server.Port={$port} -v Server.DefaultDocument=server.php -v Server.ErrorDocument404=server.php");
        } else {
            throw new Exception("HHVM's built-in server requires HHVM >= 3.8.0.");
        }
    } else {
        passthru("{$binary} -S {$host}:{$port} {$base}/server.php");
    }
}

/**
 * Get the console command options.
 *
 * @return array
 */
protected function getOptions() {
    return [
        ['host', null, InputOption::VALUE_OPTIONAL, 'The host address to serve the application on.', 'localhost'],

        ['port', null, InputOption::VALUE_OPTIONAL, 'The port to serve the application on.', 8000],
    ];
}
 }

kerner.php

 <?php

 namespace App\Console;

 use Illuminate\Console\Scheduling\Schedule;
 use Illuminate\Foundation\Console\Kernel as ConsoleKernel;

 class Kernel extends ConsoleKernel {
/**
 * The Artisan commands provided by your application.
 *
 * @var array
 */
protected $commands = [
    // Commands\Inspire::class,
    Commands\Serve::class,
];

/**
 * Define the application's command schedule.
 *
 * @param  \Illuminate\Console\Scheduling\Schedule  $schedule
 * @return void
 */
protected function schedule(Schedule $schedule) {
    // $schedule->command('inspire')
    //  ->hourly();
}
 }

webtec \ server.php

 <?php

 /**
  * Laravel - A PHP Framework For Web Artisans
  *
  * @package  Laravel
  * @author   Taylor Otwell <taylor@laravel.com>
  */

 $uri = urldecode(
parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH)
 );

 // This file allows us to emulate Apache's "mod_rewrite" functionality from the
 // built-in PHP web server. This provides a convenient way to test a Laravel
 // application without having installed a "real" web server software here.
 if ($uri !== '/' && file_exists(__DIR__.'/public'.$uri)) {
return false;
 }

 require_once __DIR__.'/public/index.php';

有人可以帮我吗?

0 个答案:

没有答案