Single file, headless C.M.S without third party dependencies (aka composer) – How dumb does this idea sound to you? How would you develop it?

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #2304
    Tanckom
    Participant

    Hey, so I had this idea of creating a “Single file headless C.M.S” for some years now as we go more towards REST API than having fully fledged C.M.S systems like WordPress. I also soon have to hand in my bachelor project description and thought this would be a nice project to work on.

    ## Some of the decisions why this project seems a good idea (to me) are that:
    – Single file – easy to use and upload anywhere, no need to run any commands or similar, it just works out of the box (after you configured the database which you do in the browser)
    – No third party dependencies like composer – The host where you want to upload your C.M.S might not have composer enabled
    – A smaller and better alternative to other Headless/Headful C.M.S’s which either are bloated (WordPress) or require additional server features a user might not have
    – Aimed for small to medium sized websites with small budgets and just need the basics
    – Extendable with simply creating one more file and then overwriting areas of the first file.

    ## My doubts/thoughts/concerns, on the other hands are that:
    – the whole C.M.S depends on one file. All logic, styling, javascript and markup happens inside this file. This could very likely affect performance?
    – Security wise – how bad of an idea is it to have everything in one file? What should i be on the lookout for? How much do i publicly expose that could lead to breaches?
    – It would be madness to develop only on one single file – I therefore thought about creating some kind of “development setup and structure” with multiple files and then later to combine them using a script – how would i best achieve structuring and setting this up?
    – Database – I thought about giving the user the ability to choose between flat file or mysql database to store data – this, however, requires me to create multiple query classes from ground up that probably requires a lot of work. Also, flat files sound like a very performance decreasing solution for multiple users reading/writing to them. Or is there any php class that already exists and has abstract classes for multiple databases?
    – File generation – The user should of course have the ability to upload images. Also, as soon as a user creates a new Item (maybe Post, or whatever they need it for) – I somehow need somewhere to store the api schema. Most probably inside a file. Meaning the single file will also generate several files in directories like `/api/item.php` or `/media/image.jpg`.
    – Is there a character/line limit that a single php file may have?
    – How likely am I to break something if everything happens inside one file?
    – Sqlite as database? I’ve worked with Sqlite3 before but never installed or configured it myself. Does using sqlite require you to install any engine or run any commands? Or is it also just adding some flat files and it works out of the box?

    As you might noticed, there are many concerns that keep me away from creating such a C.M.S, but the idea to do so is also very intriguing.

    How would you develop such a C.M.S?

    > I’ve seen something similar, [Adminer](https://github.com/vrana/adminer/) which is a single file alternative to phpMyAdmin. They, however, still use composer in some way.

    #2305
    jeffkarney
    Guest

    phar’s are a “single file”

    #2306
    Crell
    Guest

    1. `composer require` all of Symfony.
    2. Write a simple script that concatenates all of the files together into one massive file. (You’ll need to do some rewriting around namespaces.)
    3. Ship that.

    That’s going to be a massive, many-MB, unmaintainable mess. Which… is exactly what it would be if you wrote it yourself, too.

    The idea of a “single file application” doesn’t scale past undergraduate classes. They get into tens of thousands of lines much faster than you think, and if you don’t think so, it means you haven’t built a CMS yet. Even a REST-only CMS is *big*.

    Also, configuring the DB from the browser means having to write config to disk from a web process. That’s a security hole. If it’s single file, that means writing to your application code from the web process. That’s a security hole that’s already exploited. (Yes, some older applications do that. They are bad and should feel bad.)

    Also, any web host that doesn’t offer Composer out of the box has no business hosting PHP in 2020, and you should do your part to ensure they go out of business.

    Especially with PHP 7.4 and preloading, there is exactly zero benefit at runtime to being one big file. If anything, having multiple files so you can skip including the ones you don’t need on a given request is better for performance.

    Basically, every assumption you’re making is wrong. Sorry.

    #2307
    colshrapnel
    Guest

    I have a feeling that problems you are trying to solve just do not exist

    – multiple files are easy to use and upload anywhere as well.
    – composer is just a php script. you don’t have to “enable” it anywhere
    – smaller is again a dubious benefit. It’s 2020 now, not 1990. Disk space is cheaper than you think
    – better is a subjective notion, especially for an application that doesn’t exist and conceived based on such peculiar ideas
    – “multiple query classes from ground up that probably requires a lot of work” is the key phrase actually, revealing that you have no idea what is the actual amount of work lying before you
    – “Aimed for small to medium sized websites with small budgets and just need the basics” – literally any other CMS. The number of files do not affect the price. Did I tell you that disk space is cheap nowadays? On the other hand, for a small business, an existing ecosystem, with thousands free themes and plugins is vital. Whereas your file would be hard to tune or extend.
    – “Extendable with simply creating one more file and then overwriting areas of the first file.” is an oxymoron or rather a joke.

    #2308
    SignpostMarv
    Guest

    If you’re going to make terrible ideas into a single-file cms, why not use `__halt_compiler();` and stash the data into the file itself?

    #2309
    Theycallmelife
    Guest

    In short, yes – I don’t think this is a very good idea. Working with a monolith file like that is going to be a nightmare.

    In regards to dependency management, transportability doesn’t mean anything in lieu of usability; are you saying no dependency manager (composer) or no third party dependencies in general? Either way, you’re going to write custom code for everything that you would otherwise use 3rd party dependencies for?

    Targeting small to medium sized businesses? How are they going to use and/or extend it? Even if you could get a minimal viable product up and running, imagine trying to explain it to another developer… it might make sense in your head, but nothing like this exists in the wider developer ecosystem for good reason, meaning no one would try to learn it or pay for it, once they knew how the project was architected.

    Sounds interesting for a pet project, but this architecture is very counterintuitive. Modern CMS’ are specifically architected to avoid some of the pitfalls you’re creating by building a CMS in this way. You could build it and make it work as you see fit, but you’re fitting a square peg in a round hole. Sounds like you’re concerned with the “how” of getting it done instead of “why”. Just because you can do it that way, doesn’t mean you should.

    Good luck. Gonna take a lot longer than your school’s deadline.

    #2310
    eurosat7
    Guest

    A bachelor project …

    What do you want to show?

    “I can break most common industry standards and do wild stuff and… buzzword it to be easy and expandable and gizmo!”

    I think you are better off by defining your goals first – and then find something suitable to show off your skills.

    Back then (2002) I wrote something like a simplified phpmyadmin (not knowing that it already existed) and having it working was only a footnote on my result sheet. More important was what I did and why and showing my schedule and documentation. And having a structured code base helped a lot. (and showing my commits in a cvs as proof)

    #2311
    adrianmiu
    Guest

    Short answer: javascript.

    Long answer: you build a project with dependencies over multiple files and you build the source code to be a single, minified file, the `index.js` of your app.

Viewing 8 posts - 1 through 8 (of 8 total)
  • You must be logged in to reply to this topic.