Skip to content

u/websanova

In this archive from Apr 2020 to Dec 2026

6
posts
20
comments
0
media
96
score

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

Not sure, but I just went through porting my clients DNS to Cloudflare and setting up Mailgun for them and going through bot/prompt debug to try to verify it all looks good. Was just thinking a lot of that could be automated via a script or something, perhaps with some email send tests. Haven't really dug into it yet though, so not sure how much could really be automated that way.

1 points

hmm, so faster than just doing something like...?

$file = fopen($file);
$data = [];
$count = 0;
$block = 10;

while (($line = fgets($file)) !== false) {
    $data[]= $line;

    if (++$count >= $block) {
        runSomeInsertCode($data);
        $data = [];
        $count = 0;

        // Adjust block here based on time here...
    }
}

fclose($file);
1 points

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

Another scenario could be where you want to keep track of total number of posts per category, so you could display that easily without having to run total counts each time.

Which then also allows sorting by most popular categories and other analysis that may come up.

In general doing it in DB will likely allow you to more easily deal with future scenarios.

1 points

Hmm, yea, could work, but I guess needs to implemented in each controller method. I suppose could write some helper for that, but was kind of thinking with middleware might be better to capture the route and do it by the path.

Only thing is I can figure out how to detect a redirect in the middleware, since I store old urls for redirects.

1 points

End of this list.

Back to top

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.