简体   繁体   中英

Page not found in Laravel production

In my web.php file, i have a the below route and it works fine

Route::get('users/xml', function() {
    $merchants = DB::table('merchants')->where('published', '1')->get();

    $xml = new XMLWriter();
    $xml->openMemory();
    $xml->startDocument();
    $xml->startElement('markers');
    foreach($merchants as $merchant) {
        $xml->startElement('marker');
        $xml->writeAttribute('id', $merchant->id);
        $xml->writeAttribute('name', $merchant->merchant_code);
        $xml->writeAttribute('address', $merchant->address);
        $xml->writeAttribute('lat', $merchant->lat);
        $xml->writeAttribute('lng', $merchant->lng);
        $xml->endElement();
    }
    $xml->endElement();
    $xml->endDocument();

    $content = $xml->outputMemory();
    /*File::put(storage_path().'/file.xml', $content);*/
    return response($content)->header('Content-Type', 'text/xml');
});

However, when i push my code to production(Nginx), the page is not found.

I have found the solution in the laravel.log file! The reason why it is not loading is because the class XMLWriter is not bundled with the php server on Vultr(Nginx). So i went to the terminal and typed

yum install php-xml

Voila, it works!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM