Skip to content

u/SeerUD

In this archive from Jun 2013 to Apr 2026

13
posts
583
comments
2
media
2k
score

You don't need a course to build a framework. To start, you can think about how to solve a problem yourself. What problems does Laravel solve? DI, database access, maybe logging, forms, security, so on. They're packaged together nicely and interoperate nicely. Okay, you now have some requirements - start building something!

1 points

Symfony wasn't unopinionated, just less opinionated. There were still recommended ways to do things in Symfony, like there was in Laravel. Bundles and their structure was a good example I suppose, as most bundles you saw had very similar structures for the core elements (controllers, entities, config, repositories, templates, etc.)

I haven't written PHP for about 5 years though now, so things have probably moved on since, I wouldn't know!

1 points

One huge benefit of Next.js is that you can genuinely provide a better user experience for your users. By using the same code on the backend and your frontend you're able to do things like do the initial page load on the server (meaning the client doesn't get met with a big load of nothing until the static assets have loaded, they actually get the full page), but then when they do have those static assets Next.js has built-in support for things like preloading links on hover, and client-side routing can then take over. With PHP you'd be refreshing between every page, and you wouldn't be able to do the preloading (at least not without reinventing the wheel and a lot of effort).

Instead of using plain JavaScript for things like triggering a side menu, you are forced to use React State and code tons of lines of code for something that should honestly take 2 or 3 lines total.

There's 2 things here really:

  1. The difference in code size probably isn't as big as you think, because when you're thinking about React you might also be thinking about the "HTML" you're writing in your components - just remember, that HTML is still somewhere in your PHP app (just in a place that's much more disconnected from your JS, meaning you might forget that the two are linked...)
  2. Even if there is slightly more code with the React approach in the end, the approach is much more maintainable in the long run. Why? Because you're driving your UI and state with data, not by the current state of the DOM. If you're doing that with Vanilla JS then you're already on your way to creating a little library / framework of your own. Taking this data driven approach (and in general a component driven approach) makes things significantly easier to unit test for example.

On the topic of unit testing, that separation between your client-side code and your server-side code with PHP makes a lot of things trickier to test compared to just testing your components once (with a single approach and set of tooling / reporting) with something like Next.js.

Here's a sidebar example with plain React. Going back to what I was saying earlier, if you take out the lines for imports, styles, the HTML (I assume your PHP code imports things, that your PHP site has styles, and your PHP site has some kind of templates / HTML somewhere), then you're actually left with pretty much 3 lines of code to make a menu. The thing to keep the state, the thing to open the menu, and the thing to close the menu. If you wanted it to be a bit fancier you could add an animation to it to make it fade in with CSS.

This isn't to say that every site should be built in React, you should choose the right tool for the job - and choosing that tool also needs to factor in your experience. If you only have really light JS usage in your application and you know Symfony really well or something, then using that is a very sensible approach. Just so you're aware though too, there are frameworks that even build on things like Next.js, like Blitz (I've never used this personally).

0 points

Personally I'd go with something like i3. Get a shortcut key cheat-sheet and just get used to what you can do with it. If you want something slightly prettier, get i3-gaps (personally I don't use the gaps, but do hide edge borders and have smart borders on, etc.)

From there, there aren't many things that i3 does itself that look "pretty" or "bad". I tend to turn title bars off, so the only thing from i3 ends up being the border around windows. I think you can do things like add a border radius even now. Choose some colours and you're done.

Honestly, that's the easy part out of the way though. I think this goes for most window managers that stand on their own like this though. You'll want some kind of bar (I use KDE these days, but used to use PolyBar - the one that comes with i3 is okay, but not as pretty). You'll probably want to figure out things like locking your screen (i3lock?), setting your background (feh), maybe a screensaver or automatic locking. Then you get onto some more serious stuff; if you have a laptop then you'll want to think about what happens when you plug in a USB device, or a display for that matter (displays aren't automatically configured out of the box). What do you want to happen when your device sleeps and wakes up (and do you have any bugs with those things)?

It's not for the faint of heart; however, I do think it's a MUCH better idea to go through figuring these things out on your own. If you're on a desktop it's a lot simpler too as you don't need to worry about sleep / wake the same, or plugging in displays. If you do it yourself though, then you'll actually come to understand the components of the "desktop environment" you're building, why you want them, how to fix them, so on. If you just pull someone else's config you'll have no idea what's in it, why it's there, how to fix it, how to maintain it, etc.

I really enjoyed messing with i3 personally, I started writing my own applications do things like configure displays when they're plugged in, and I made a grid-based workspace manager with a GUI overlay for i3 (so you could move around workspaces in 2D directions like up, down, left, and right), and I started working on an alternative to PolyBar at one point. It took me until that point to realise that this was all quite fun, but I could be making other things I wanted to make, instead of making a desktop environment that I'd then use to make those other things - particularly when you consider things like Gnome and KDE exist and are not too heavyweight, look fine, and do all of those things I mentioned and more for you.

3 points

Congratulations on getting something like this up and running. It really reminds me of how I started out programming. I spent all summer between years at University learning PHP and built things in a very similar way. This is how a lot of people start out with PHP. You've already managed to figure out the kind of logic you need to solve some of these common problems, and you've tackled some parts in the right way (e.g. using the built-in password_* functions).

There's a few things to be weary of when working with databases. One of the main most common attacks that new developers fall for is SQL injection attacks. I'm pretty sure places like this are vulnerable. It's really easy to avoid though, a very common approach is to use prepared statements which mysqli does support. If you take raw user input like that and drop it straight into a query then it means that someone can post a SQL query and your code will just execute it. If you use a prepared statement the query and it's arguments are sent separately - this way even if some malicious user did put in another query then it wouldn't actually be executed, it'd just be fed as one of the arguments to the query you're trying to run.

With regards to folder and file structure; this is fine now - you're getting to grips with logic, etc. One specific area I can see to improve this sort of structure is separating things that are pages, and things that you want to use in pages (i.e. the things you've used $includeCheck for). If you move those include-only files out of the web root then they'll no longer be accessible from a browser, but they can still be accessible from PHP - meaning you no longer need that check.

Still on folder and file structure though; there are much more common, much more scalable and maintainable approaches though. I'd advise you to take a look at a well-written framework like Symfony. It might take some getting your head around, but it'll tackle a LOT of common problems you have for you (handling forms, HTML templating, authentication and authorisation, database querying in a more object-oriented way via an ORM, etc.). Symfony, like many frameworks, also has that separation I mentioned for includes. It also uses a front controller, so essentially you just have a single PHP file exposed in your web root and all of your other PHP code is hidden.

10 points

OP has responded to you, I don't think he's necessarily understood what you're asking though there. It's not about nested vendor/ directories, as I don't think they generally exist (not sure if Composer strips them out automatically). It's for looking at a given parent directory (i.e. where you store you PHP projects on your machine), and then cleaning up all vendor dirs you don't need within that parent directory.

3 points

I think a lot of people aren't understanding what your intent is here. I only understood after looking at what npkill does. Maybe this explanation will be clearer for people:

killposer finds Composer-created vendor directories on your system, lists their path and size, and allows you delete ones that you don't need to free up storage space.

Does that sum it up?

I guess one major difference between PHP and NPM is that generally PHP dependencies don't also pull in things like binaries or source code for other languages that needs compiling, and the problem of the explosive dependency trees isn't really there with PHP either - having 500MiB of vendor dirs on your system isn't really a big deal. You probably have a way more stored in your browser cache, or downloaded Spotify music or something. NPM can take GiBs of storage though.

14 points

KDE on an XPS 15 9560. I was running i3-gaps, but I got tired of bugs in things like polybar, and wanted some of the other niceties that you get with a full DE, like desktop icons, a more unified design, and having the whole platform move forward at once.

Don't get me wrong, I really enjoyed i3, I made some custom applications for it, for example a grid based workspace switcher where you move in directions not by workspace number, and something to configure displays automatically when plugged in. Eventually I tried to write my own bar, it was going very well honestly, but I realised I was spending a lot of time working on things that I'd have to maintain that I was only making to use my machine. Others may have found it useful too, but I tried a load of DEs and KDE provided the experience I enjoyed the most. I configured it in a way inspired a little by my i3 setup, but obviously I don't have tiling (which I do miss, but I now just have keyboard shortcuts to move and resize windows so its not really much of a loss - you don't spend very much time positioning or resizing windows either way), and the only other main thing is that you don't get separate workspaces for each screen like you do with i3.

Eventually I might try get i3 to play with KDE. I know it's possible but I didn't get it to be a very smooth experience last time. My workspace switching app did work with it though.

3 points

Each to their own. I get frustrated by the lack of options available in Gnome. I customise KDE a little once when I set it up on a new machine, once in a blue moon, and don't really have to look at the settings again - but it's nice that I can tweak things from the UI to be exactly what I want.

I prefer GTK generally in terms of design, but Qt has really grown on me. Also, I don't like how inconsistent the Gnome UI is, there's the bits that look like your GTK theme, and then bits that look like Gnome with some colour differences. KDE is very consistent with it's styling.

1 points

I'm not sure to be honest. I personally just turn them off, and often have a CDN in front of things exposed on the web, e.g. Cloudflare, and they often override the server tokens with their own.

3 points

In fairness, interest in PHP is dropping. You can see that from things like Google Trends, or just looking at the results of things like the StackOverflow developer survey.

There are a TON of people using PHP probably without realising it with solutions like WordPress, or that don't care because they're more interesting in the products built with PHP, like Drupal, etc. That's not to say those solutions are bad by any means, they've been successful because they're good products for the people that use them. As time goes on though, I think less people will actually choose products built with PHP, just as less people are choosing to build bespoke solutions in PHP. For example, I lead the development efforts at the company I work for, but before I even started in this position the company was moving away from PHP to a SSR React frontend, and a mainly Go backend with some bits of Node.js and Java thrown in.

ALL of that being said, PHP is far from dead yet. There are still tons of PHP jobs. You can make good money working with PHP. It can definitely be very satisfying and rewarding working with PHP.

11 points

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.