How to run laravel on Xampp without Artisan - Hack The Tech - Latest News related to Computer and Technology

Hack The Tech - Latest News related to Computer and Technology

Get Daily Latest News related to Computer and Technology and hack the world.

Monday, June 7, 2021

How to run laravel on Xampp without Artisan

I am using Xampp for my project where I have PHP files. I have another file uploading laravel project which I want to open when a user clicks on a button in PHP file. So, I want that laravel project to work in Xampp so that I can complete that functionality of clicking button in "library.php" opening "showForm.blade.php" and on clicking button in "showForm.blade.php" sends request to "web.php"

"showForm.blade.php" is like this:

<!-- showForm.blade.php -->

<!DOCTYPE html>
<html lang="">
    <head>
        <meta charset="utf-8">
        <meta name="viewport" content="width=device-width, initial-scale=1">

        <title>Google drive integration in laravel</title>
    <!-- CSS only -->
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.1/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-+0n0xVW2eSR5OomGNYDnhzAbDsOXxcvSN1TPprVMTNDbiYZCxYbOOl7+AMvyTG2x" crossorigin="anonymous">
    </head>
    <body>
        <div class="container">
            <div class="row">
                <div class="col-12">
    
                <br><br><br>
                    <!-- store route as action -->
                    <form action="/upload" method="post" enctype="multipart/form-data">
                    @csrf
                    
                    <!-- value Part -->
                    

                    <input type="file" class="form-control" name="thing" id="title">
                    <br>
                    <input type="submit" class="btn btn-sm btn-block btn-danger" value="Upload">
                    </form>
                </div>
            </div>
        </div>
    </body>
</html>

web.php is:


<?php

use Illuminate\Support\Facades\Route;
use Illuminate\Support\Facades\DB;
use Illuminate\Http\Request;
/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/

Route::get('/', function () {
    return view('showForm');
});

Route::post('/upload', function (Request $request) {
    $name=$request->file("thing")->getClientOriginalName();

    Storage::disk("google")->putFileAs("",$request->file("thing"),$name);
    $url=Storage::disk('google')->url($name);
    DB::insert('insert into books (Title, Url) values (?,?)', [$name,$url]);
})->name("upload");

I tried these steps:

  1. "server.php" to "index.php" .
  2. copy ".htaccess" from public to root directory.

but doing this will open the showForm.blade.php but on clicking upload does not send the request, rather says that localhost/upload URL not on the server.

Please don't say this is duplicate. I view the questions here and tried solving my issue but it does not submits the form.

EDIT In the httpd.conf I changed the DocumentRoot "C:/xampp/htdocs" to DocumentRoot "C:/xampp/htdocs/webdev/example-app" Doing this solved the issue, now the upload request is executing, but the issue is I am not able to open other files in htdocs.

Also, as far as I understood this issue was resolved because when I click upload button then request is transferred to localhost/upload which is not the desired path but now because document root is the project folder so it becomes the correct path.

but now as the document



source https://stackoverflow.com/questions/67862260/how-to-run-laravel-on-xampp-without-artisan

No comments:

Post a Comment