Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

vincent15000's avatar

vincent15000 liked a comment+100 XP

2h ago

Executing app resulting from app:build results in a runtime error

Code in bootstrap/app.php: $dotenv = Dotenv\Dotenv::createImmutable(DIR . '/../');

Why is DIR not returning the full path of the file currently being executed (.../builds) and instead returning (.../builds/appName/bootstrap) ?

vincent15000's avatar

vincent15000 wrote a reply+100 XP

5h ago

Executing app resulting from app:build results in a runtime error

Ok thank you.

When you need help, it's important to share with us all the informations you can give us.

Without knowing that you were using laravel-zero, it's not possible for us to guess.

So now restart from the beginning ... what have you done step by step until you get the error ?

Step 1 : ... ?

Step 2 : ... ?

...

vincent15000's avatar

vincent15000 liked a comment+100 XP

5h ago

Executing app resulting from app:build results in a runtime error

Ok: Here is summary of current status of issue: Did deploy process of appName app:build which created appName in the (new) builds directory When execute appName get runtime error Uncaught Dotenv\Exception\InvalidPathException: Unable to read any of the environment file(s) at ... /builds/appName/bootstrap/../.env]. This runtime error is due to there not being a appName directory under builds directory (there is appName executable under builds)

Why is it looking for appName directory under builds directory?

vincent15000's avatar

vincent15000 liked a comment+100 XP

5h ago

Executing app resulting from app:build results in a runtime error

From created a Laravel CLI app via laravel-zero new applicationName

vincent15000's avatar

vincent15000 liked a comment+100 XP

5h ago

Executing app resulting from app:build results in a runtime error

From created a Laravel CLI app via laravel-zero new applicationName

vincent15000's avatar

vincent15000 wrote a reply+100 XP

1d ago

Executing app resulting from app:build results in a runtime error

You don't answer the question : where does the app:build command come from ?

vincent15000's avatar

vincent15000 liked a comment+100 XP

1d ago

Executing app resulting from app:build results in a runtime error

php appname app:build -vvv results in runtime error: [_HumbugBox6ab58bf96c33\KevinGH\Box\Composer\Throwable\UndetectableComposerVersion] Could not detect the Composer version: The command "'/usr/local/bin/compose r' '--version' '--no-ansi'" failed.

Exit Code: 1(General error)

Working directory: /home/whatever

Output:

PHP's phar extension is missing. Composer requires it to run. Enable the ex tension or recompile php without --disable-phar then try again.

vincent15000's avatar

vincent15000 liked a comment+100 XP

1d ago

Executing app resulting from app:build results in a runtime error

On local laptop (WSL): php appname app:build does work are generates the deployed executable appname under the builds directory. But, when execute appname (via ./appname) get: PHP Fatal error: Uncaught Dotenv\Exception\InvalidPathException: Unable to read any of the environment file(s) at ... bootstrap/../.env].

vincent15000's avatar

vincent15000 liked a comment+100 XP

1d ago

Executing app resulting from app:build results in a runtime error

On local laptop (WSL) the appname above the builds directory executes without any runtime error

vincent15000's avatar

vincent15000 liked a comment+100 XP

1d ago

Executing app resulting from app:build results in a runtime error

On remote serverthe appname above the builds directory executes without any runtime error

vincent15000's avatar

vincent15000 liked a comment+100 XP

1d ago

Executing app resulting from app:build results in a runtime error

Is best practice to deploy the application to production with app:build and use the production executable?

vincent15000's avatar

vincent15000 wrote a reply+100 XP

1d ago

Executing app resulting from app:build results in a runtime error

Give more details about your problem, please ... because app:build doesn't exist, so you probably have installed a package or you wrote it yourself.

vincent15000's avatar

vincent15000 liked a comment+100 XP

1d ago

Executing app resulting from app:build results in a runtime error

What is app:build? This command is not built-in, did you write it?

vincent15000's avatar

vincent15000 liked a comment+100 XP

1d ago

vincent15000's avatar

vincent15000 liked a comment+100 XP

1d ago

Executing app resulting from app:build results in a runtime error

Certainly! Here is a solution for the issue described in the Laracasts post:


Problem Description:
After building your Laravel app (using something like php artisan app:build, e.g. with Laravel Zero), when you execute the built app, you receive the error:

PHP Fatal error:  Uncaught Dotenv\Exception\InvalidPathException: Unable to read any of the environment file(s) at ... bootstrap/../.env

Solution:

The error indicates that, when running the built application, it is trying to load the .env file but cannot find it at the expected location. This usually happens because:

  • The .env file is not present in the directory from which you're running the built application.
  • The built app is packaged, but the working directory or expected path for .env is incorrect.

How to Fix:

  1. Ensure there is a .env file available where the application expects it. This is usually in the same directory where you run the built app, or at bootstrap/../.env relative to when it's run.

  2. Copy the .env file to the correct place, for example:

    cp .env.dist .env
    

    Or manually ensure a .env file is present next to your built executable or where it expects to find it.

  3. Alternatively, if your built package is deployable (e.g., a PHAR/executable), and you want to support running it from anywhere, you can either:

    • Instruct users to place their .env file next to the executable, or
    • Modify your code to look for .env in the current directory or in a configurable place.

Example (Laravel Zero):

If you want your Laravel Zero app to not throw an error when .env is missing (i.e., optional env), you can update your app.php (or bootstrap/app.php) to make Dotenv loading optional:

// In bootstrap/app.php or similar
if (file_exists(__DIR__ . '/../.env')) {
    Dotenv\Dotenv::createImmutable(base_path())->safeLoad();
}

or, with Laravel built-in functionality:

$app->loadEnvironmentFrom('.env');

(But make sure .env exists.)

Extra:
If you are distributing a built app to others, include in your README/deployment instructions that users should copy and configure their own .env from your provided .env.example or similar file.


Summary:
Copy your .env file to the location expected by your built application. If it's not required, update your bootstrap to not throw on missing files.


Let me know if you need more help!

vincent15000's avatar

vincent15000 liked a comment+100 XP

1d ago

Executing app resulting from app:build results in a runtime error

Executing app resulting from app:build results in a runtime error: PHP Fatal error: Uncaught Dotenv\Exception\InvalidPathException: Unable to read any of the environment file(s) at ... bootstrap/../.env].

vincent15000's avatar

vincent15000 wrote a reply+100 XP

3d ago

I accidentally deleted a Controller. How to recover?

That's unfortunately the case for a lot of people here ;).

vincent15000's avatar

vincent15000 liked a comment+100 XP

3d ago

I accidentally deleted a Controller. How to recover?

@adamnet Are you actually going to reply? And say why you weren’t using source control when you’ve been told by multiple people to do so for months now…? Or will you just come back in a couple of months’ time with a yet another new post on how you’ve lost work and want to know how to get it back?

vincent15000's avatar

vincent15000 liked a comment+100 XP

6d ago

IT9

Is this a how to use maatwebsite/excel article?

vincent15000's avatar

vincent15000 liked a comment+100 XP

6d ago

verify mail

This happens because the starter kits (Breeze/Jetstream) wrap that verification route in the auth middleware by default. When you open the link in a different browser, you're a "guest," so the middleware intercepts the request and redirects you to the login page before the verification logic even runs.

To fix this, you need to allow guests to hit that endpoint and manually find the user since $request->user() won't be available.

First, in routes/auth.php, move the route outside the auth middleware group, Then, you'll need to tweak the VerifyEmailController. Since you aren't using the auth middleware anymore,

vincent15000's avatar

vincent15000 liked a comment+100 XP

6d ago

Can't browse site after clonning git repository

You're mixing yarn and npm, which seems weird to me. Use npm run dev instead of yarn dev.

The bundler is complaining about not finding resources/admin/sass/admin.scss. Does it exist?

vincent15000's avatar

vincent15000 liked a comment+100 XP

6d ago

Can't browse site after clonning git repository

Hello,

Using Laravel 12, I cloned my github repository into c:\wamp64\www

I ran: composer install

composer update

npm install

I copied my .env file from a previous folder I had for this project.

I ran yarn dev, got these errors:

(!) Failed to run dependency scan. Skipping dependency pre-bundling. Error: failed to resolve rollupOptions.input value: "resources/admin/sass/admin.scss". at resolvePath (file:///C:/wamp64/www/mysite.local/node_modules/vite/dist/node/chunks/config.js:31449:29) at async Promise.all (index 2) at async computeEntries (file:///C:/wamp64/www/mysite.local/node_modules/vite at async scan (file:///C:/wamp64/www/mysite.local/node_modules/vite/dist/node/chunks/config.js:31388:19) at async file:///C:/wamp64/www/mysite.local/node_modules/vite/dist/node/chunks/config.js:34131:15

I have the right database credentials and the actual database.

Trying to run the site in the browser, I get this message:

Looks like there’s a problem with this site

Firefox can’t connect to the server at mysite.local What can you do about it?

Try connecting on a different device. Check your modem or router. Disconnect and reconnect to Wi-Fi.

What am I doing wrong please?

vincent15000's avatar

vincent15000 wrote a reply+100 XP

6d ago

vincent15000's avatar

vincent15000 liked a comment+100 XP

6d ago

verify mail

I think there was a video from Jeffrey about passwordless authentication

vincent15000's avatar

vincent15000 liked a comment+100 XP

1w ago

IT9
  1. resources/views/products create.blade------------------------------------------------------------------------------------------------------------------- @extends('layouts.app')

@section('content')

<div class="bg-white rounded shadow p-6">
    <form method="POST" action="{{ route('products.store') }}">
        @csrf

        {{-- Name --}}
        <div class="mb-4">
            <label class="block text-sm font-medium text-gray-700 mb-1">Name *</label>
            <input type="text" name="name" value="{{ old('name') }}"
                   class="w-full border rounded px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-blue-400 @error('name') border-red-400 @enderror">
            @error('name') <p class="text-red-500 text-xs mt-1">{{ $message }}</p> @enderror
        </div>

        {{-- Category --}}
        <div class="mb-4">
            <label class="block text-sm font-medium text-gray-700 mb-1">Category</label>
            <input type="text" name="category" value="{{ old('category') }}"
                   class="w-full border rounded px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-blue-400">
        </div>

        {{-- Price & Quantity side by side --}}
        <div class="flex gap-4 mb-4">
            <div class="flex-1">
                <label class="block text-sm font-medium text-gray-700 mb-1">Price *</label>
                <input type="number" name="price" value="{{ old('price') }}" step="0.01" min="0"
                       class="w-full border rounded px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-blue-400 @error('price') border-red-400 @enderror">
                @error('price') <p class="text-red-500 text-xs mt-1">{{ $message }}</p> @enderror
            </div>
            <div class="flex-1">
                <label class="block text-sm font-medium text-gray-700 mb-1">Quantity *</label>
                <input type="number" name="quantity" value="{{ old('quantity', 0) }}" min="0"
                       class="w-full border rounded px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-blue-400 @error('quantity') border-red-400 @enderror">
                @error('quantity') <p class="text-red-500 text-xs mt-1">{{ $message }}</p> @enderror
            </div>
        </div>

        {{-- Description --}}
        <div class="mb-6">
            <label class="block text-sm font-medium text-gray-700 mb-1">Description</label>
            <textarea name="description" rows="3"
                      class="w-full border rounded px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-blue-400">{{ old('description') }}</textarea>
        </div>

        <div class="flex gap-3">
            <button type="submit"
                    class="bg-blue-600 text-white px-5 py-2 rounded hover:bg-blue-700 text-sm">
                Save Product
            </button>
            <a href="{{ route('products.index') }}"
               class="px-5 py-2 rounded border text-sm text-gray-600 hover:bg-gray-50">
                Cancel
            </a>
        </div>
    </form>
</div>

@endsection edit.blade------------------------------------------------------------------------------------------------------------------- @extends('layouts.app')

@section('content')

<div class="bg-white rounded shadow p-6">
    <form method="POST" action="{{ route('products.update', $product) }}">
        @csrf @method('PUT')

        {{-- Name --}}
        <div class="mb-4">
            <label class="block text-sm font-medium text-gray-700 mb-1">Name *</label>
            <input type="text" name="name" value="{{ old('name', $product->name) }}"
                   class="w-full border rounded px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-blue-400 @error('name') border-red-400 @enderror">
            @error('name') <p class="text-red-500 text-xs mt-1">{{ $message }}</p> @enderror
        </div>

        {{-- Category --}}
        <div class="mb-4">
            <label class="block text-sm font-medium text-gray-700 mb-1">Category</label>
            <input type="text" name="category" value="{{ old('category', $product->category) }}"
                   class="w-full border rounded px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-blue-400">
        </div>

        {{-- Price & Quantity --}}
        <div class="flex gap-4 mb-4">
            <div class="flex-1">
                <label class="block text-sm font-medium text-gray-700 mb-1">Price *</label>
                <input type="number" name="price" value="{{ old('price', $product->price) }}" step="0.01" min="0"
                       class="w-full border rounded px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-blue-400 @error('price') border-red-400 @enderror">
                @error('price') <p class="text-red-500 text-xs mt-1">{{ $message }}</p> @enderror
            </div>
            <div class="flex-1">
                <label class="block text-sm font-medium text-gray-700 mb-1">Quantity *</label>
                <input type="number" name="quantity" value="{{ old('quantity', $product->quantity) }}" min="0"
                       class="w-full border rounded px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-blue-400 @error('quantity') border-red-400 @enderror">
                @error('quantity') <p class="text-red-500 text-xs mt-1">{{ $message }}</p> @enderror
            </div>
        </div>

        {{-- Description --}}
        <div class="mb-6">
            <label class="block text-sm font-medium text-gray-700 mb-1">Description</label>
            <textarea name="description" rows="3"
                      class="w-full border rounded px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-blue-400">{{ old('description', $product->description) }}</textarea>
        </div>

        <div class="flex gap-3">
            <button type="submit"
                    class="bg-blue-600 text-white px-5 py-2 rounded hover:bg-blue-700 text-sm">
                Update Product
            </button>
            <a href="{{ route('products.index') }}"
               class="px-5 py-2 rounded border text-sm text-gray-600 hover:bg-gray-50">
                Cancel
            </a>
        </div>
    </form>
</div>

@endsection index.blade------------------------------------------------------------------------------------------------------------------- @extends('layouts.app')

@section('content')

{{-- Flash Messages --}} @if(session('success')) {{ session('success') }} @endif

{{-- Table --}}

{{-- Pagination --}}

@endsection

  1. resources/views dashboard------------------------------------------------------------------------------------------------------------------- {{ __('Dashboard') }}

reports.blade------------------------------------------------------------------------------------------------------------

@extends('layouts.app')

@section('content')

{{-- Summary Cards --}}

{{-- By Category --}}

{{-- Full Product List --}}

@endsection

vincent15000's avatar

vincent15000 liked a comment+100 XP

1w ago

IT9
  1. Exports ProductReportExport ----------------------------------------------------------------------------------------
vincent15000's avatar

vincent15000 liked a comment+100 XP

1w ago

IT9
  1. maatwebsite/excel for Excel exports.

composer require maatwebsite/excel

php artisan vendor:publish --provider="Maatwebsite\Excel\ExcelServiceProvider" --tag=config

  1. App/Models

Product ---------------------------------------------------

vincent15000's avatar

vincent15000 liked a comment+100 XP

1w ago

IT9
  1. web.php------------------------------------------------------------------------------------------------------------------
vincent15000's avatar

vincent15000 liked a comment+100 XP

1w ago

IT9

Question?

vincent15000's avatar

vincent15000 wrote a reply+100 XP

1w ago

IT9

Do we have to guess your question ?

vincent15000's avatar

vincent15000 liked a comment+100 XP

1w ago

Database Replication

@eskiesirius This is literally the definition of premature optimisation…

vincent15000's avatar

vincent15000 wrote a reply+100 XP

1w ago

I accidentally deleted a Controller. How to recover?

Perhaps he has generated the code with an AI ... sorry I just want to make a joke ;).

vincent15000's avatar

vincent15000 liked a comment+100 XP

1w ago

Delete migration file in project. Way to restore?

No, I do not use git at all.

@adamnet May I suggest you start doing so? And it will save you in situations like this.

vincent15000's avatar

vincent15000 liked a comment+100 XP

1w ago

Delete migration file in project. Way to restore?

@shez1983 The term here is commit. You don't need to upload changes anywhere as long as you get in the habit of committing frequently.

@adamnet It looks like VSCode has this feature, sort of. Type CTRL/CMD + P, and find "Local history: Find Entry to Restore". You should find your file contents there. Unlike in PHPStorm, it doesn't look like you can straight up restore the file from history (the IDE gets confused because the file doesn't exist), but at least you can copy the contents and re-create it.

vincent15000's avatar

vincent15000 liked a comment+100 XP

1w ago

Delete migration file in project. Way to restore?

but it sounds like h e was working on it and didnt get a chance to save/upload it - in which case git wouldnt have helped..

vincent15000's avatar

vincent15000 liked a comment+100 XP

1w ago

Delete migration file in project. Way to restore?

This would be a good time to start.

vincent15000's avatar

vincent15000 liked a comment+100 XP

1w ago

vincent15000's avatar

vincent15000 liked a comment+100 XP

1w ago

Delete migration file in project. Way to restore?

Not sure how VS Code handles local history... any chance that you had committed the file to git?

vincent15000's avatar

vincent15000 liked a comment+100 XP

1w ago

Delete migration file in project. Way to restore?

I use Visual Studio Code editor. There is an option there: Open the Command Palette by pressing Cmd+Shift+P Paste the phrase "Local History: Find Entry to Restore" . I could not find the file Thanks for answering.

vincent15000's avatar

vincent15000 liked a comment+100 XP

1w ago

Delete migration file in project. Way to restore?

Was it ever commited in git?

Otherwise, if using PHPStorm, there is a Local History in File >> Local History >> Show History. Other editors/IDEs may have a similar feature?

vincent15000's avatar

vincent15000 liked a comment+100 XP

1w ago

Delete migration file in project. Way to restore?

Earlier today I created a migration file for creating a table with a lot of columns, foreign keys etc. Accidentally I deleted it. Is there any way to restore it? Is there a recycle bin into the project?

vincent15000's avatar

vincent15000 liked a comment+100 XP

1w ago

I accidentally deleted a Controller. How to recover?

Oh, you're right: thread.

@jussimannisto I seldom forget things I’ve read or seen. It’s a blessing and a curse 😅

vincent15000's avatar

vincent15000 wrote a reply+100 XP

1w ago

vincent15000's avatar

vincent15000 liked a comment+100 XP

1w ago

I accidentally deleted a Controller. How to recover?

I accidentally stabbed myself in the foot. Is there any way to unstab my foot? I only have two feet and this one is used to kick the cat so I cant afford to lose it.

vincent15000's avatar

vincent15000 wrote a reply+100 XP

1w ago

verify mail

What you want is not the normal behavior.

If you really want this, I suggest you to generate your own temporary email verification link and handle the verification by your own in a controller.

vincent15000's avatar

vincent15000 liked a comment+100 XP

1w ago

verify mail

In a new laravel site/ app with starter kit the registration is not what I expect. After registration, the user must register his email. So in My model I added MustVerifyMail. After registering, the https://{mysite}/verify-email page will be loaded. You can choose to log out or resend verification mail. The email comes in. but can only work in the open browser where you have not yet logged out. If you are logged out, the link will not work and you will go back to the login page. the email_verified_at is not entered in the database.

The routes auth.php contain the routes linked to the middleware auth.

Route::get('verify-email/{id}/{hash}', VerifyEmailController::class)->middleware(['signed', 'throttle:6,1'])->name('verification.verify');

and

Route::get('verify-email', EmailVerificationPromptController::class)->name('verification.notice');

How can I make it so that verification is possible even if the user is already logged out or is using a different browser.

vincent15000's avatar

vincent15000 wrote a reply+100 XP

1w ago

Event-Driven Architecture, do I need it?

Not sure that this comment is really the best answer ;).

vincent15000's avatar

vincent15000 wrote a reply+100 XP

1w ago

I'm having problems on deciding an architecture for sub navs, and I'm having trouble on deciding how to manage the page without refresh without messy code.

The only way to update the content of a page without refreshing the page is to use AJAX request, so you have to use JavaScript, send the requests from JS (for example with axios or the native JS function fetch) and update manually the DOM.

You can do this an easier way using either AlpineJS, or HTMX, or Turbo, or simply why not Livewire.

https://alpinejs.dev/

https://laravel.com/docs/13.x/blade#rendering-blade-fragments

https://laracasts.com/series/crafting-web-applications-with-htmx

https://htmx.fr/

https://turbo.hotwired.dev/

https://livewire.laravel.com/

If you want to keep your code light, I suggest you rather AlpineJS or HTMX or Turbo.

vincent15000's avatar

vincent15000 liked a comment+100 XP

1w ago

I'm having problems on deciding an architecture for sub navs, and I'm having trouble on deciding how to manage the page without refresh without messy code.

I'm creating a community based SN, I created manage section for community owners, and there is nav on top like general, privacy, sections (flairs), users (follow, requests), posts (requests, pinned, etc.) inside. I created blade pages for them, but inside them there are sections again. Like Followed, Requests, Pinned, Removed etc. Making separate pages for them would be bad. I don't know if I should just send arguments ?filter=request and display it based on that. What would be professional way for this type of sub sections (navs)?

Also after creating some things I just realized that I have to make sure the page is not getting refresh with the actions like follow, pin, remove, reject, accept etc. There are tons of them, I did follow, delete with the async fetching with js. And also realized I have to fetch posts with it too because of pagination. I don't want it to refresh for next other 20 posts every time. I'm wondering if it would be ok to use tons of async fetch and dom manipulation in the page.

I'm doing this with laravel and without front frameworks. I am having trouble on how to do the architecture so it won't bite me back. I would appreciate your suggestion and examples on these things.

Edit: also, which is the better way, using toggle on action like ban/unban, like/dislike, follow/un, pin/unpin, or creating separate routes and functions for them?

vincent15000's avatar

vincent15000 liked a comment+100 XP

1w ago

Observer and scheduled publish dates

You already hit the nail on the head observers only fire on database operations, and time passing isn't a database operation.

Like the others mentioned, a scheduled command running everyMinute(). Instead of adding a published_processed_at timestamp though, I usually just rely on a status column (e.g., switching it from scheduled to published). Grab records where published_at <= now() and status === 'scheduled', fire your service, and update the status.