▲ 14 r/PHPhelp

Is it worth it to go without a framework?

I've been using PHP casually for decades. In the last two years I've started to try to take it more seriously, and that inevitably led me to Laravel. For basic CRUD sites, Laravel has been a godsend, allowing scaffolding of a ton of functionality pretty quickly, Blade templates make sense to me, the workflow works for me.

Deployment is where things have been tricky. Since I do this as a hobby and my user count is in the single digits per day, I use shared hosting. Deploying a Laravel application to shared hosting is pretty rough. I've managed it, but queries are extremely slow, everything feels sluggish, etc.

So, in an attempt to weigh the pros and cons, I went to packagist.org and started to look into cobbling together my own packages to find a happy medium between writing all my own libraries (I do not relish the idea of going back to this) and full-blown frameworks like Laravel.

But, I've run into an issue I did not expect: everything seems to be deprecated in the latest versions of PHP. FastRouter's page one Github documentation references classes that don't seem to exist in the project anymore, meaning that basic functionality required me digging into the code to find out why classes weren't there. PHP-Auth throws sixteen deprecation flags when just creating the instance of the Auth class.

The standalone Blade templating engine doesn't work. Twig does - and actually works as described, so kudos to them.

All of this to state my theory: Everyone in PHP has gone to Laravel or Symfony and never looked back. This has inevitably led to all the standalone packages rotting.

Or, I'm an idiot and doing something obviously wrong.

To my question: Is it even worth it to try to cobble together something small and simple anymore? Just with FastRouter, PHP-Auth, and Twig templating I'm finding my workflow is SIGNIFICANTLY slower than just using Laravel. And PHP-Auth won't even work, so I'm back to rolling my own, which I do not want to do.

I just want some simple session authenticating, I don't need OAuth2.

Anyway, I'm open to hearing discussion on this, and I'd appreciate those more knowledgeable than I chiming in.

Thank you.

reddit.com
u/KaedenCraft — 23 hours ago

Storing Player Position into Data Storage

execute store result storage klc:test Pos double 1 run data get entity @ s Pos[0] 1

No matter what I try, it stores an integer value instead of the full double value. What am I missing?

reddit.com
u/KaedenCraft — 24 days ago

Working With Entities in a Scoreboard

Working on a minigame that uses Pigs to store map data. Basically the pig's UUID is the scoreboard entity for storing information for each available "map" in the game, and you can simply rename the pig with a nametag to change the name of the map, etc. I did this years ago when there were spawn chunks, and it worked great with the pigs in the spawn chunks: I could store all kinds of scoreboard data with the pig entity as a key for what belonged to what map. I was kind of proud of myself, as it ended up being a very versatile solution.

And why a pig? I don't know, they're cute and easily nametag-able.

But now without spawn chunks, I'm reconsidering, and don't want to use things like /forceload if I don't have to. There are a lot of new fancy bits with datapacks since I last delved in (2+ years ago), so I was wondering if there was a more elegant solution to this.

I need to be able to store a unique, dynamically-generated identifier between multiple scoreboards that - if possible - will not require an entity to be loaded to work. As far as I know there's not a way to have dynamic Scoreboard entries, but if somebody has an interesting solution I'd love to hear it.

Example use case:

I create a pig with UUID 1234 and store it in scoreboard_maps with a score of 1 (its mapid). I can now set map_spawn_x, map_spawn_y, and map_spawn_z with 1234 and its scores will be the coordinates to teleport players to when the map is loaded. But now that I'm outside of the view distance of 1234, I can't access any of its entity data from the new location I've teleported to.

I've considered weird solutions like creating a Marker with copied data that goes to the map with the players, but that will create complications with having to keep the two of them synced with updates (and beyond render distance of each other), or if players disconnect in the middle of a match, what kind of cleanup do I have to do so I don't have infinitely stacking markers with identical data, etc.

Thank you in advance!

reddit.com
u/KaedenCraft — 28 days ago

When to Fetch Sets of Data

I'm building a browser-based character sheet editor for a D&D-style Tabletop RPG. All the data is shoved into databases in the backend, and I'm just now doing the frontend. This is my second attempt on this project (massive changes on the creator's end, necessitating changes form me) so I thought I'd take the opportunity to "do it right", as it were.

In the previous iteration, I fetched all the data into a single JavaScript object I dubbed "The Compendium" and then queried that object's methods as needed to display the data. I've switched to using a Vue frontend and am....unsure if this is the recommended method? Should I fetch everything up front into a single object like before, or is it best practice to instead wait until a user clicks "Abilities" and then fetch all the abilities to populate a selectable interface?

Does it matter?

I've only ever used my own home-grown frameworks before, so moving to Vue (with a Laravel backend) has been a lot, and I'm just looking for suggestions on how to architect this.

There are a number of "lists" of data that would need to be fetched to make this work: Abilities, Spells, Traits, Perks, Classes, Languages, etc. Open to suggestions, as I've never really asked people who "do this stuff" how they'd do it, so here I am.

Thank you!

reddit.com
u/KaedenCraft — 2 months ago