Wave on Digital Ocean - Error 500
Hey 👋
Did you install this on a Droplet or the App Platform?
Usually the installation itself is the exact same as it would be for any other standard Laravel application. There should be no additional steps that you need to take.
The 500 error is just a generic error. To see the actual error that is causing the problem, you can check your laravel log at sotrage/logs/laravel.log
. Feel free to share the exact error that you are getting here so I could advise you further.
- Bobby
Thanks, I got this error: production.ERROR: error connecting to database!(https://cdn.devdojo.com/images/june2024/download.png)
I use the app but in the installation, I didn't inserted database settings and .env is not in github.
Do you explain how to deploy it in one of your video?
Thanks
Hey!
Yep, you would definitely need a database!
What you can do is to use the deploy button from the readme file:
- First update the reference in the deploy template here to point to your repository
- Then in the README file update the URL of the deploy button to also point to your Wave repo
After you commit those two changes, just click the button in the README file of your GitHub repo, or visit the deploy link directly:
https://cloud.digitalocean.com/apps/new?repo=https://github.com/YOUR_GH_USERNAME/wave/tree/main
That will create all of the necessary components for your app including a dev database.
Alternatively, you would just create a database via your DigitalOcean account:
https://docs.digitalocean.com/products/databases/
And then attach it to your App:
https://docs.digitalocean.com/products/app-platform/how-to/manage-databases/#add-a-database-to-an-app-using-the-control-panel
Note that you should not add your .env file to your Git repo as this is a huge security risk. With the app platform you manage your env variables directly though there rather than an env file.
Let me know if you have any questions.
- Bobby
Thanks, it is working.
But I got another problem using Voyager. When I'm creating a new BREAD, I create a model using command: php artisan make:model Mydocs and it is create the file at: App\Models\Mydocs.php
I'm getting the error: local.ERROR: Target class [App\Mydocument] does not exist. {"userId":1,"exception":"[object]
In a Voyager video i see that it create it in: App\Mydocs.php instead of: App\Models\Mydocs.php
Do you have an Idea? Thanks
Happy to hear that it is working :)
The error that you are getting now should be straight forward to fix as it seems quite self-explanatory, I think that you just need to use the correct model name when creating the BREAD:
Make sure to use the correct model name based on the one that you've created hen using the artisan command.
Let me know how it goes!
Hey,
Here is a playlist of videos where Tony goes over on how to build a SaaS with Wave:
It includes quite a few videos.
If this is not exactly what you are after, feel free to share more about what type of CRUD you are interested in, is it just the CRUD in Voyager, or is it for your frontend, are you using Livewire or just standard controllers, and etc.
Hey!
In this case it will be just as with any other standard Laravel application.
In Voyager you will have your standard BREAD which will mainly be used by site admins.
And then on the frontend, you will create your routes and controllers as you would with any Laravel application.
Creating Routes and Controllers
-
Define Routes: Add your routes in
routes/web.php
:Route::resource('books', 'BookController');
-
Create Controller: Generate a controller:
php artisan make:controller BookController --resource
-
Implement Controller Methods: In
app/Http/Controllers/BookController.php
, add methods for CRUD operations:// Display a listing of the resource. public function index() { $books = Book::all(); return view('books.index', compact('books')); } // Show the form for creating a new resource. public function create() { return view('books.create'); } // Store a newly created resource in storage. public function store(Request $request) { $request->validate([ 'title' => 'required', 'author' => 'required', 'year' => 'required|integer', ]); Book::create($request->all()); return redirect()->route('books.index'); } // Display the specified resource. public function show(Book $book) { return view('books.show', compact('book')); } // Show the form for editing the specified resource. public function edit(Book $book) { return view('books.edit', compact('book')); } // Update the specified resource in storage. public function update(Request $request, Book $book) { $request->validate([ 'title' => 'required', 'author' => 'required', 'year' => 'required|integer', ]); $book->update($request->all()); return redirect()->route('books.index'); } // Remove the specified resource from storage. public function destroy(Book $book) { $book->delete(); return redirect()->route('books.index'); }
Creating Views
-
Create Blade Templates: Create views in
resources/views/books
for listing, creating, editing, and showing books. Example forindex.blade.php
:@extends('layout') @section('content') <h1>Books</h1> <a href="{{ route('books.create') }}">Add New Book</a> <ul> @foreach ($books as $book) <li>{{ $book->title }} by {{ $book->author }} ({{ $book->year }}) <a href="{{ route('books.edit', $book->id) }}">Edit</a> <form action="{{ route('books.destroy', $book->id) }}" method="POST"> @csrf @method('DELETE') <button type="submit">Delete</button> </form> </li> @endforeach </ul> @endsection
-
Create Other Views: Similarly, create
create.blade.php
,edit.blade.php
, andshow.blade.php
.
Feel free to share more information about the end goal here and I can share more concrete example.
- Bobby
Hi, After deploying to DO, I'm getting a 500 error that is not exist in local. The only things i think about is the use of CURL that should be enabled. After research, I don't know how to enable curl in the DO app itself. I've tried app-get... but the command is not recognized. What is the best practice do enable curl in DO App? Thanks
Hi,
You can enable any PHP extension by just specifying them in the composer.json file.
Here is an example:
Just add "ext-curl": "*",
after line 13.
After that, make sure to run composer update and commit the composer.json and lock files to your repository.
Here is a link to a discussion that explains this:
https://www.digitalocean.com/community/questions/how-to-enable-php-redis-on-an-existing-digital-ocean-application
Also, whenever you get a 500 error, it is best to check the laravel log, to see what the actual problem is, the 500 error is just a generic error which does not give any information on what the problem might be, but that information should be available in the log.
Let me know how it goes.
Hey!
The easiest way to edit the php.ini
settings on the DigitalOcean App Platform is to add a .user.ini
file to your codebase with the following lines in it. These lines will set the values for max_execution_time
:
max_execution_time=60
https://www.digitalocean.com/community/questions/how-to-update-php-ini-on-a-digitalocean-app
However note that there might be some other hard limits on the App Platform that would not let you increase the max execution time indefinitely.
Let me know if this works.