samuelgfeller / slim-example-project

Complete Real World Slim 4 Example Project with Front- and Backend, Automated Testing, Auth System, Permissions, Localization and more.
https://samuel-gfeller.ch/slim-example-project
MIT License
34 stars 4 forks source link

Hi Samuel. I am getting an error when I try to run the code for the first time. #3

Closed markjcorrigan closed 7 months ago

markjcorrigan commented 7 months ago

I am new to slim 4. I have bought all of Daniel's books and wanted to learn within his repo. I have had a torrid time of it trying to get it to work. Then I found your codebase. I am blown away by the detail I find. Phew... Amazing.

May I ask a question: I added the following scripts to composer.json. "start": "php -S localhost:8080 -t public/", "dump": "composer dump-autoload -o", I have set up the database and have tables inserted with seed:minimal. I have set up config/env/env.php I have xampp running on my machine for the database and it is running. I then run the "start" script to get up and running. However, when I put in credentials the system crashes. I.e. in phpstorm I get the following error Script php -S localhost:8080 -t public/ handling the start event returned with error code -1073740791 Annotation 2024-02-15 220716 and the server stops dead (per attached).
I am sure I have done everything correctly but there are a lot of moving parts. Possibly you have seen above before. PS I am really excited to dig into your code and use it to help me learn slim 4 in a manner that aligns with Daniel's 3 books I have bought. Again. Awesome work. Thank you for the leg up to help me to understand what is happening within the piping of the framework.

samuelgfeller commented 7 months ago

Hi Mark I'm glad if the documentation and this project can be helpful in your journey of learning PHP with Slim.

If you have XAMPP up and running, you don't need the built-in PHP web server. You start the web server and database in the XAMPP control panel, place your project in c:\xampp\htdocs and you should be able to access the application via localhost/your-app-name.

Try it again without php -S localhost:8080 and let me know how it looks.

In case you installed the project using composer create-project like mentioned in the installation guide, it installed the v0.4 which is pretty outdated. I will release a new version soon but in the meantime you can fork the project or install it again via the git clone feature implemented in PHPStorm: image image

If you did that, forget what I said.

markjcorrigan commented 7 months ago

codeholic dashboard Hi Samuel. Some feedback and you can close my question.

I did try to run the localhost/projectname in my browser working on Xampp in localhost but did not have much success. Strange. But no problem because... A while ago I set up an ability to run projects from my home server directly onto the internet. I use no-ip.com and their DUC application. I also use Certbot to make sure that the "https" padlock (or whatever their new switchy icon is now) is running. I was able to download sourcecode (not sure the version) from your github link and then fire up your incredible application in two url's I have created and play around with it. I will keep the one as your example and the other as a project I am tracking in git and which I can work on. When I shut down my server at home my internet presence disappears which suites me just fine.

Phew, again, I am blown away by the depth and skill I see in your code (all using the latest slim 4 framework).

May I switch to a quick question. I see that you are not using twig but create pages in another method (using php and js I think) that has me stumped. Is your project a SPA?

My goal, if this is possible, will be to try to use your framework and try to create a basic user login system to a landing page (dashboard) and a bunch of other internal pages only accessible to authorised. Doing this, I hope, will help me to understand your approach, and learn from what you are doing. I think this will take me many months (years ;~) to get right. BUT, having your stable example of your project using the slim 4 (optiz) skeleton as a guide and baseline I believe I will be able to focus on learning how to get to my project goal without spending most of my time fighting with the framework trying to get it and many outdated (dependencies) to work. I.e. before your code I tried other boiler plate projects using slim 4 but most are outdated and built in a sort of a Laravel way. Hopefully, I will also see and finally figure out (with your clear examples) how you are using the DI container and autowiring the different features into it etc. etc.. I will also need to cross reference your excellent notes and documents and also will continue to use Daniel's slim 4 books. A VERY STEEP LEARNING CURVE is ahead for me, but at least it is focused and in a tested and working environment that you have created. Again. Thank you for sharing this by making it available with and for someone who's goal is only to learn how to use Slim 4 and like you have done, leverage the Daniel Optiz skeleton and approach (use this books to implement a slim 4 focused internet based solution [without all the hidden stuff that Laravel has that I struggle to fully understand]).

samuelgfeller commented 7 months ago

I did try to run the localhost/projectname in my browser working on Xampp in localhost but did not have much success. Strange.

This is strange indeed! Running it on your home server with your config is awesome for a dev/prod environment but you should still be able to serve it locally for development easily. If you want I can help you debug the issue with XAMPP. Have you enabled the apache & mysql module and placed the project in the xampp/htdocs folder? image

Thank you for the very positive feedback! This project has been my full-time job the last 3 years and I'm happy that it finally comes to an end now and if you can find value in it, that's double mission accomplished for me.

Have you heard of Xdebug? That tool is an absolute must have.

I see that you are not using twig but create pages in another method (using php and js I think) that has me stumped. Is your project a SPA?

You're right, I chose to not use twig but a PHP template renderer which is way more lightweight, native and doesn't require a custom syntax. I have written a chapter about how the front end is rendered, which library is used and it also addresses the SPA question (spoiler: I'm not a fan of SPAs). Documentation: Template Rendering.

I must say, I'm not really a front-end guy. The dependency that front-end frameworks bring, the overhead for the client and the fact that a new one is trending each month/year or the complexity of tools like web pack scare me away.
I want code that is performant, durable and works for a long time without a lot of maintenance, even if it might take a little longer to write. That's why I chose to write everything javascript in pure vanilla js which has come a long way and I'm hopeful that it will continue to evolve into a more mature language with maybe one day native type safety (type annotations work great for now).

My goal, if this is possible, will be to try to use your framework and try to create a basic user login system to a landing page (dashboard) and a bunch of other internal pages only accessible to authorised Hopefully, I will also see and finally figure out (with your clear examples) how you are using the DI container and autowiring the different features into it

That is a great goal and the true way to learning things. You could strip down the example project, take everything logic out and build your app with the resources available and you'll learn a ton. I've tried to address most aspects of building such an app including DI, authentication and authorization in the documentation (table of content in the sidebar).

I wrote the documentation precisely for people like you, trying to uncover a lot of "behind the scenes" things that aren't being explained properly in most guides that just "expect" you to have this knowledge already.

If anything is a bit unclear or you find things that could be clarified, explained better please don't hesitate to write me. Here in the issues or via email contact@samuel-gfeller.ch. You're feedback is very valuable to me.

And if you have other questions in your learning process, you're also welcome to write.

markjcorrigan commented 7 months ago

Thank you very much. I did figure out the localhost/myproject issue. I was putting in https://localhost/myprojectname. When I left off the http(s) it worked perfectly. I have a Udemy course on Xdebug and am working through it at the moment. I will definitely take up your advice and pin this down for my projects. I agree fully with your advice about front end complexity. I have spent loads of time trying to learn / unravel this and my time would far better off not being dragged into the next fad. I will definitely take you up on your offer to contact you with specific questions. Again, thank you very very much. Your work for me (I am reading through each of your documents as we speak) is a vertiable oasis in the desert! Keep well. Mark.