flightphp / core

An extensible micro-framework for PHP
https://docs.flightphp.com
MIT License
2.6k stars 407 forks source link

Example projects - What would that look like ? #503

Closed steinhaug closed 5 months ago

steinhaug commented 6 months ago

This might sound like a dumb question, but what about adding an example project or two? I see the project page has descriptions for how to use everything, but since you made all that effort why not add a few examples? For someone like me not having done school to learn theese concepts, I understand the benefits such frameworks give with security, but examples are great this way I get the best practices from the start.

Say a project that has a welcome page and a contact page, where the contact page can recieve feedback via post.

And maby an advanced page using URL rewrite and what you consider being the advanced parts. I noticed this was explained in the readme. An example with table, where you could filter it from URL? Or think of a function that fetches articles from /YEAR/MONTH/DAY if given, or /YEAR as the more usual) Again as an example using flightphp and how to set it up correctly.

Someone? I would love to see some practical examples, if not here maby setup a new repository for such exmaples. Maby this would be the way to go, as anyone could easily contribute there?

n0nag0n commented 6 months ago

Did you happen to see the readme for this repo? I recently just added several various examples that were across github.

fadrian06 commented 6 months ago

The truth is, I did have in mind making an interactive guide on how to build a simple application with Flight and add it as a tutorial section on the homepage.

fadrian06 commented 6 months ago

A FAQS or Cheat Sheets section for the homepage They would also come in luxury

n0nag0n commented 6 months ago

Oh I'd like to see something more formal for sure, but what I put on the readme "stops the bleeding" for now. We did just need something.

paxperscientiam commented 6 months ago

While not good enough for the examples page, some of y'all might interested in seeing how you might integrate select Laravel/Illuminate features with Flight -- https://github.com/quidprobros/worth-the-weight/blob/18d3efd6471170119a75d4d8a91eaaea15778cb4/wtw.paxperscientiam.com/index.php

Probably the most useful is the database stuff

n0nag0n commented 6 months ago

That is definitely a more complex example of how to implement an app, but it does highlight some of the features for sure.

This is more of a personal decision, but I.......tend to stay away from Laravel-y things. I think the performance benchmarks on Laravel and Lumen speak for themselves. TechEmPower Benchmarks Web Frameworks Benchmarks Granted benchmarks don't tell the full story, but it definitely tells a story. And when I have to set aside hours to go over documentation, it just makes me wanna curl up in a ball and be sad :cry:

paxperscientiam commented 6 months ago

Hah, I understand.

Do you think it would be useful to provide a concise example of login mechanism integration? If so, I could whip up something.

Or, whatever else. I'm not picky.

fadrian06 commented 6 months ago

This is more of a personal decision, but I.......tend to stay away from Laravel-y things. I think the performance benchmarks on Laravel and Lumen speak for themselves. [TechEmPower Benchmarks]

I was thinking in a benchmark too

fadrian06 commented 6 months ago

Do you think it would be useful to provide a concise example of login mechanism integration? If so, I could whip up something.

If you want to provide some examples, you could put in a new docs/examples/ folder, put the examples in markdown or php, make a PR and I will be happy to review it. ;D

steinhaug commented 6 months ago

@n0nag0n

Did you happen to see the readme for this repo? I recently just added several various examples that were across github.

Yes I did, but check this out... Take the first link, flight-skeleton, I could post the same question in that repository. Actually I would like to ask you, what is the difference in using this repository and the flight-skeleton repository ? Unless I am mistaken, this repository has the exact same files as the skeleton ? Isn't this repository a skeleton aswell ? I do see that the flight-skeleton repository states it has added support for Sass and Twig which tells me alot of choices have been made there for the usual workflow. Anyhow...

@fadrian06

I was thinking in a benchmark too

While on topic with benchmarks and stuff, I do not have the knowledge to understand the nuances different frameworks like this favours. What are the main objectives of this framework for the hardcore user, what is the goal for this framework? Since you mention benchmarking I'm guessing that this framework has to be compared to others? I didn't see any others mentioned in the readme.

My thoughts, from a self learned experience...

Again as a selv learned PHP developer without an IDE, using Visual Studio Code and lo and behold ... jQuery. Maby there arnt that many left of us, that doesnt know what code smells, design patterns and such is. It is definately important stuff, so I envy you that had teachers that hammered theese concepts into your head from day one... Having to learn this at the end - instead of the beginning - of my coding experience .... well, definately there are thousands of hours to be saved by having a solid understanding from the start instead of hacking everything together.

Obviously I need to do a lot of changes to my code for making it work with this framework, or any MVC framework for that matter. So again I would love some basic sample projects for dummies, making sure I do not ignore the best practises this framework probably are trying to favour.

I am also interested in understanding where the framework starts and where it ends, as I am guessing that the difference with with framework and say Laravel is handling of whatever. Say session, database layer and such - im guessing this framework does not do that.

I'm thinking maby I should atleast put together two use cases from PHP files, after all... I know that part :D This is my problem coming from a background without being taught what MVC is from day 1 - maby this sounds stupid but to me this sounds like something I would benefit from:

  1. A very simple website with two pages, a page listing things and a page to add more things. This showcases linking the pages, posting the data and such and possibly how one needs to restructure the business logic and so.

  2. A typical webpage with typical features. A page with login managing session, having javascript using AJAX and URL rewrites for sorting something(/YYYY/MM/DD/). Lets not forget a search so I know if your framework is doing anything with user submitted data, or if there are something I need to do to comply with the framework.

Does this sound like two use cases to utilize the framework for ? Atleast there you have the two examples that would make my day :)

This would be two examples without the need of database or other libraries to obfuscate what is the point of the execersice.

magikstm commented 6 months ago

@steinhaug

FlightPHP is a Framework to build RESTful web applications (APIs). It can also be used to build other types of projects or websites, but you would have to code or add several parts yourself.

This basic usage is a demo on how it could be used with composer: https://github.com/flightphp/core#basic-usage

The skeleton one uses FlightPHP, but it refers to it: https://github.com/markhughes/flight-skeleton/blob/main/composer.json

I am also interested in understanding where the framework starts and where it ends, as I am guessing that the difference with with framework and say Laravel is handling of whatever. Say session, database layer and such - im guessing this framework does not do that.

FlightPHP doesn't do that. It is really really basic. Depending on your use-case it may not be a good fit.

A very simple website with two pages, a page listing things and a page to add more things. This showcases linking the pages, posting the data and such and possibly how one needs to restructure the business logic and so.

Yes. But, if you need to add user authentication to that... It makes the project really more complicated if you're not used to these concepts (you would have to add authentication yourself).

A typical webpage with typical features. A page with login managing session, having javascript using AJAX and URL rewrites for sorting something(/YYYY/MM/DD/). Lets not forget a search so I know if your framework is doing anything with user submitted data, or if there are something I need to do to comply with the framework.

Yes. But, you would need to create authentication, search and sorting yourself.

FlightPHP isn't feature-complete. It is more like a simple and stable foundation to which you add pieces to.

FlightPHP is closer to Slim Framework, but with a few less features. It is easier to use though.

n0nag0n commented 6 months ago

So my background is my degree is in business management, and I optimized my responsibilities in my old job enough where I taught myself how to code by checking out a PHP/MySQL book from the library and I practiced during my work. So I haven't had any formal programmer training with theories and such. I just went to Google everyday and eventually got better at what questions to ask.

As for what this framework is, it's a basic framework to get some ideas off the ground. It's not meant to be an all encompassing "covers every base" kind of framework, those are full stack frameworks; this is intentionally a micro-framework. It gets enough of the job done to cover a lot of the basics, but it won't cover everything.

As for a skeleton project, I'm not opposed to that. I might get some time to set something up like that to be an official framework skeleton with best practices and all that. In my ~15 years of coding and managing a 600k line codebase where it grew from 1 cPanel server to about 100 servers in total, I've picked up a thing or two about how to code and security and all that.

Lot's of good ideas in here, just know that this framework will never be Laravel, Cake, Zend, Symfony, etc. It might get to a point where it's a lighter version of something like Fat-Free, and then it'll have some additional modules that can be added to your project, but those wouldn't be anything in the core.

n0nag0n commented 6 months ago

This seemed to be a hot topic for a little bit, so I spent some time over the past few days coming up with a skeleton project for Flight. Could you all give me some feedback on it?

https://github.com/flightphp/skeleton

steinhaug commented 6 months ago

n0nag0n

As for a skeleton project, I'm not opposed to that. I might get some time to set something up like that to be an official framework skeleton with best practices and all that

This sounds great. Also, I'll give the skeleton a test drive.