Skip to content

u/websanova

In this archive from Apr 2020 to Dec 2026

6
posts
20
comments
0
media
96
score

Top posts

Laravel API Starter

Not sure starter apps are even relevant anymore, but this is something I've been using for years in my freelance work. Just did a full rebuild with more modern tooling and workflow and decided to open source it. Pairs with a standalone Vue app/admin SPA and a flows repo. Any feedback would be greatl...

7 points1 comments
Open on Reddit

Browser Direct to S3 Spaces (DO) Uploads.

Trying to figure out this direct uploads, and keep getting a CORS issue from Digital Ocean, no idea what they want from me. I just keep getting the ... Access to XMLHttpRequest at '....' from origin '...' has been blocked by CORS policy: Response to preflight request doesn't pass access control chec...

1 points1 comments
Open on Reddit

Top comments

Yes, it's a common example.

Only thing I can think is that it let's us clean things up a bit with a generic helper function which can remove some of the open/close boilerplate for us.

function iterateOverFile(String $file) {
     $file = fopen($file);

    if (!$file)
        die('file does not exist or cannot be opened');

    while (($line = fgets($file)) !== false) {
        yield $line;
    }

    fclose($file);
}

So we can just call...

foreach(iterateOverFile($file) as $row) {
    doSomeStuffWithRow($row);
}

Currently I have some scenarios like that, but I just use a callback which I believe in the end would be the same thing.

For example...

function iterateOverMe($range, $cb) {
    for ($i = 0; $i < $range; $i++) {
        $cb($i);
    }
}

iterateOverMe(5, function ($i) {
    echo $i;
});

So in file example it would look something like...

iterateOverFile($file, function ($row) {
   doSomeStuffWithRow($row);
});

Though looking at it now, I suppose an iterator is "cleaner" solution if we potentially need access to data in the parent scope which would avoid having to use use.

6 points

Seems interesting, but where do you define the schema descriptions?

Might be interesting to setup for my starter app, I currently just did this with a little pass through shim:

https://github.com/websanova/starter-laravel-api/blob/main/app/Mcp/Tools/ApiTool.php

So then you can just setup classes as needed for what you want to expose, for example:

https://github.com/websanova/starter-laravel-api/blob/main/app/Mcp/Tools/App/Bookmark/ListBookmarksTool.php

Lets you keep the MCP code a bit more isolated.

3 points

Subreddits

Keyboard shortcuts

Move and act

jork
Next / previous post or comment
Enteroro
Open the post
f
Open the media viewer
s
Save
h
Hide (the toast has Undo)
Tab
Right after an action: the toast's Undo
x
Collapse the comment
v
Next layout: cards, compact, grid

Go to

/
Search
gthenh
Home
gthena
All
gthens
Subreddits
gthenl
Library
?
This list
Esc
Close a menu or this list

In the viewer

←or→
Previous / next file
↑or↓
Previous / next post
korj
Previous / next post
Space
Play / pause
m
Mute
z
Zoom
s
Save
o
Open the post (on its own page: back to it)
Esc
Close

Keys do nothing while you type in a box.