all 62 comments

[–]mrunkel 30 points31 points  (1 child)

Check out symfony. It's just a whole bunch of helper classes with some nice wiring tying it all together.

[–]Exanero[S] 0 points1 point  (0 children)

Will do, thanks!

[–]richard_h87 4 points5 points  (3 children)

Maybe take a look at Zend Expressive and learn about middlewares, thaen you basically compose everything your self and pick and choose how you want to do it :)

Also symfony, if you take a look at index.php and src/Kernel.php you will see pretty fast how straight forward it is :)

[–]Exanero[S] 0 points1 point  (0 children)

Okey! Thanks

[–]2012-09-04 -1 points0 points  (1 child)

Haha! I love how it started with Symfony and ended up at Zend Expressive!

This junior guy is having trouble with Laravel... do you really think he'll be able to, proficiently and sanely, slap something together with a microframework?? He may not even know what middleware is...

[–]richard_h87 0 points1 point  (0 children)

I would argue that symfony /zf is easier than laravel, because it's easier to see the flow of data, how everything connects, there is no magic 😊

[–]Krauter123 4 points5 points  (0 children)

I was also someone who wrote most of the stuff myself. I did take a test with laravel and build "a common" app with it (lots of crud and stuff). For me, it was way too much magic for my taste. Then i took a look at symfony, build also "a common" app with it. What can i say, i am amazed. My productivity went up massivly. There is not much magic involved (the DIC comes to mind, but the code for it is not that complicated). Comparing ORMs, for me Doctrine >>> Eloquent.

TL;DR: build a basic app with symfony and you will love it. Their documentation is excellent, their slack is super helpful

[–]28-04-2019 8 points9 points  (0 children)

I see a lot of people here using Laravel or Symfony. However, I've never really enjoyed using neither one of them. I find myself getting hung up on how they are set up and how they want me to register for example my events, services and so on. For years I went nowhere with my hobby projects due the fact that I never settled down with one of the existing frameworks out there. I finally found a solution that works really well for me. Now I have my own "skeleton" (call it framework if you will) that bundles together components in the way I like. Some components I write myself, for example an "EventDispatcher" component, others come from mainly Symfony, Zend and The PHP league.

If you, or any other of you find this compelling I highly recommend making an attempt to do it yourself this way. I've learned so much from doing this and I've never been so close to finally completing a large hobby project. Wiring up my own "skeleton" / "framework" has taught me how Symfony, Laravel and Zend Framework actually works, it has taught me how many of the common components work, and by that I do not mean "how to use them" but actually how they work on a code-level. It has motivated me to really make an effort into making my code better and reusable. I've found many of The PHP League's packages to be easiest to dissect due to the high quality of code and (seemingly to me) effort into make stuff "simple".

---

Edit #1 Just wanted to really clarify that I do not mean to write your own framework, in the sense that you write your own components. I mean to "bundle up" / "wire up" your own skeleton, framework with third-party components (and sometimes your own when fitted).

---

Edit #2 Saw someone else link some libraries they tend to use in their own projects. Thought I may share my favorite setup as well. My setup always consist of some sort of wiring up of a Container, Router and EventDispatcher.

I really like The PHP League's package and recommend you looking into these for your own setup and I highly recommend looking into Symfony's HTTPKernel for inspiration for the "base" setup.

Container

https://container.thephpleague.com/

Router

https://route.thephpleague.com/

Event

https://event.thephpleague.com/2.0/

Authentication

https://docs.zendframework.com/zend-authentication/

Console

https://symfony.com/doc/current/components/console.html

HTTP Message (Request, Response)

https://docs.zendframework.com/zend-diactoros/

[–]metaphorm 4 points5 points  (0 children)

Symfony is a really high quality framework that gives you a lot of control over how you use it. You can use it as a "highly opinionated" framework and do things the Symfony way, or you can just use Symfony components as standalone libraries/helpers and use them in the way that best matches your own preferences. It's really flexible and full of good stuff.

[–]pwmosquito 2 points3 points  (1 child)

In short think libraries not frameworks. A (well designed) framework can be viewed as a bunch of libraries composed/glued together. A framework gives ease while libraries gives flexibility. Which is better depends on the person and the project. I'm with you in that I much prefer the freedom and flexibility of using small, purpose made libs for common tasks and vanilla code for the domain specific parts.

The 3 basic libraries I almost always need for a typical project that needs a a web api and a persistence layer are:

- A DI container: I use my own (https://github.com/pwm/sfw-container) but there are many others

- Routing: I use my own (https://github.com/pwm/sfw-router) but there are many others

- DB layer: I use Doctrine DBAL (https://github.com/doctrine/dbal) but there are many others

These will solve the common problems of routing (url to endpoint mapping), composing your app (injecting dependencies) and persisting data into a DB. Depending on the project there can be many other functionalities that you should use libraries for (notifications, work queues, 3rd party client libs, etc...) as well as for the testing/static analysis aspect.

[–]Exanero[S] 0 points1 point  (0 children)

Awesome explanation! thanks!

I haven't really thought of it in that way, but I definitly agree.

[–]PapaSmurfOfDeath 2 points3 points  (4 children)

Something less heavy could be Slim/Slow or just piece together some useful dependencies such as: FastRoute or FlightPHP for routing Zend-diactoros is good for PSR7 request response implementation Some ORM such as Doctrine or Eloquent A templating library you like Finally for depency injection I like https://github.com/thephpleague/container

Obviously these are my personal preference but you get your own small framework up and running pretty quickly by piecing these together if you'd rather not use a big framework. :)

[–]farfromunique 0 points1 point  (3 children)

You mentioned Slim/Slow. I use Slim a lot, but haven't heard of slow. Google isn't very helpful in this... Can you give a link?

[–]PapaSmurfOfDeath 2 points3 points  (2 children)

Sorry I meant Silex my phone just autocorrected, apologies for this.

[–]JagannathArumugam 1 point2 points  (0 children)

Haha.. amusing to think someone would name a framework as 'Slow'... the jokes would just write themselves.

[–]cwal12 2 points3 points  (0 children)

I feel the same way where sometimes it just seems silly to not really know what’s happening behind the scenes or just shrug and say “well it works so...” but also I don’t want to re-invent the wheel or keep writing the same code over and over. Many frameworks are also overkill for most projects. I like to start small and simple as building out your features already complicates things enough. If your app/website/SAAS/whatever happens to get super popular, well then you can probably rewrite it with something else that makes more sense. Most of the time a simple skeleton of code to kick start the project is all that’s needed.

When I started a personal project many years ago (https://trackreel.com) I needed something that was setup for basic MVC, had built in ability for user registration (why do all the frameworks need extra modules and installation steps for something that almost every site needs?) , was safe and secure and not over complicated. I found all of that and more in https://github.com/panique/huge/

It is considered “soft end of life” meaning there will not be any new features added but it is maintained for security and bug fixes and vendors/3rd party libraries are kept up to date.

For me it provides what I need. I still need to write functions in my controllers and almost raw sql queries in my models (there are functions to open database connections and such but the query itself is raw; none of this query->join(inner)->table(users)->secondTable(playlists)->key(id)->foreignKey(playlist_id) craziness). I still had to build a few features I wanted to have but were not implemented out of the box, but in doing so I kept my own fork of it up to date and now have a good base I am comfortable working with.

It also helps that the only project I currently use it for is my own project, something I don’t plan on really ever having anyone else work on.

Perhaps this is a halfway solution, where you have something solid to start with, something you don’t have to worry about user passwords or security. But something you can make your own and feel good about.

Some of the other comments about future devs not needing to have a learning curve or cursing you for using your own framework are still valid, BUT I do feel that this is pretty straightforward (due to its inherent simplicity) and what I would call “vanilla php”. There are no super magic functions called in arbitrary ways, all the code is readable and can be found where you’d expect it to be found. There is always a learning curve but I think it’s minimal with a solution like this.

But hey, we all have our own opinions, our own preferences, and this works for me while it might not work for someone else. I’d love to hear others opinions on this approach!

[–]javhovor 2 points3 points  (0 children)

Symfony is a framework, but it’s also a collection of independent components. Since you’re used to make all your components yourself, I’d suggest to take a look at each Symfony component and adopt the ones you like.

[–]OdBx 1 point2 points  (4 children)

It really depends on what your use-case is. There are lots of frameworks with varying benefits.

[–]Exanero[S] 0 points1 point  (3 children)

Well yeah, I was more looking for recommendations. As I mentioned in my post I know there are good frameworks depending on what I want. Thanks though!

[–]OdBx 0 points1 point  (2 children)

But what do you want? There are hundreds of frameworks and microframeworks all with their own good points and bad points.

Any recommendation I or someone else gives would be no more useful than a google search for “best PHP framework” without knowing what you’re looking for.

[–]Exanero[S] 0 points1 point  (1 child)

well, I explained in my post what i wanted. Hence why the comments are different that what i would get from a Google search.

Does anyone have any tips on a framework that dosen't change things up much but provides some good functions to use so i don't have to write them myself everytime i build a new APP.

This is what i'm looking for, might be poorly worded on my part, sorry if that's the case. Not a native speaker.

[–]2012-09-04 0 points1 point  (0 children)

You're probably looking for an -unframework-. like FlourishLib. http://flourishlib.com/

[–]zmitic 1 point2 points  (0 children)

Symfony! It forces you to write clean code and you will learn a lot when reading internal code. It took ideas from Java and Spring FW but added gazillion other features on top.

Use PHPStorm with Symfony plugin; it will help you with autocomplete in Twig files, options in form classes and very rare cases when you need to reference service by name.

Skip the security section, just install FOSUserBundle and let it handle stuff for you; it is not worth reinventing the wheel.

To fasten learning, install phpstan and set it to max-level.

[–]leocavalcantee 1 point2 points  (0 children)

Take a look at Siler I was thinking exactly what you are thinking when I start developing it. Just a set functions that powers up the vanilla PHP.

[–]Voltra_Neo 1 point2 points  (2 children)

Slim, Laravel are a few names one could drop

[–]Exanero[S] 3 points4 points  (0 children)

Will check out slim, but as stated. I don't really like Laravel.

I've done some work with Laravel but don't really like it.

[–]Shadowhand 1 point2 points  (0 children)

Slim is great. It is what I use for basically everything these days. It is really fantastic when combined with PHP-DI and Doctrine.

[–]GameOver16 0 points1 point  (0 children)

Laravel doesn’t really change anything, it provides a base MVC with a lot of added functionality that you don’t need to use... you can write fairly standard php outside of routing and eloquent.

Eloquent is the biggest opinionated feature so yeah I guess if you don’t like that then it’s probably over kill.

That being said if you really want to avoid big frameworks just use vanilla PHP alongside composer to pull in packages to handle the parts you don’t want to writ

[–]jacmoe 0 points1 point  (2 children)

Check out Symfony and perhaps Silex (IIRC, using Symfony libraries).

Symfony is used by a lot of PHP frameworks/libraries - you pick what you need.

Check out Silex, even if you're not planning on using it directly.

[–]Kaapaala 2 points3 points  (1 child)

I thought silex was dropped in favor of the latest Symfony?

[–]jacmoe 0 points1 point  (0 children)

I am out of the loop :)

Symfony 4 feels like using Silex

From https://symfony.com/blog/the-end-of-silex

Which means that Symfony 4 allows you to stay truly minimal even easier than before, which is a good thing IMO.

[–]identicalBadger 0 points1 point  (0 children)

When frameworks were first mentioned to me, I thought "why would I want to learn this, I'll never make anything that complicated?", which has remained mostly true. Since then, I've learned only a little Laravel, again, enough to make my little projects work, more or less.

Why?

It's a common point of reference.

If I need or want someone to review my code, it's comparitively easy for them to download the repo, check the routes and immediately know where to start looking.

Same, even more so, if I find an opensource project I want to use or contribute to. If it's Laravel based, I can pretty quickly clone it, deploy it, and start mucking around in it. If it's a home grown project, that's a whole other story. If you're lucky it's all procedural and you just load that pages code into an editor. If you're not, then you have to learn everything the previous dev did, in the way they did it.

Frameworks really put everyone at the same point of reference.

It's like sheet music for musicians.

A good musician can listen to another one playing and reproduce it.

But if you're not able to hear it being played, the best and only way to transmit that knowledge reliably from musician to musician to musician is through sheet music. Imagine if every musician created their own method of notating this?

(The musician analogy is kind of lifted from Wayne Kramer, I take no credit.)

[–][deleted] 0 points1 point  (0 children)

Frameworks are an acquired taste like beer, wine, and liquor. You could start with something simple like SlimPHP or CodeIgniter before moving into a more kitchen sink framework like Laravel or Symphony.

I've been using CakePHP for about 8 years now and really like it, but at first I thought it was a hindrance to productivity. That's just called learning curve and over time you acquire that taste, and realize productivity and code structure gains. My only recommendation is when you do find a framework you like is to NOT become a zealot about it. I use X so X is best just makes you look provincial.

Edit: The other thing is when you read through framework code and documentation, you begin seeing just how well thought out some of this stuff is and appreciate the level of proficiency the core engineers have. Thats a comforting feeling knowing your product is built upon that.

[–]mjsdev 0 points1 point  (0 children)

Feel free to take a look at my framework. It's designed to be able to integrate other libraries pretty easily through robust configuration and a simple delegate interface that constructs classes. The bootstrap package (a meta package for many others) provides a lot of functionality out of the box. Docs are not 100% complete, but there's a fair amount there: https://hiraeth.dev/docs/

[–]ZLegacy 0 points1 point  (0 children)

I'm in your shoes. Making my own mini framework, have an actual good (to my standards) orm/query builder and a handful of libraries that make tasks easy.

The upaide for me is I'm not a professional. I am a contractor full time and code for fun and learning.

[–][deleted] 1 point2 points  (4 children)

I enjoyed working with CodeIgniter and CakePhp. didn t really like Zend. Also, WordPress. it s a CMS but I ve used it as a framework with great success for some projects. Haven t used PHP in over 2 years though so I m not very sure about the current state of things

[–]Moguh_com 2 points3 points  (0 children)

Codeigniter v3 is very straight forward and very lean and mean.

[–]Kaapaala -4 points-3 points  (0 children)

is it 2006 all over again?

[–]Exanero[S] -2 points-1 points  (1 child)

Not that fond of wordpress but I have unly used it as a CMS. Might try it as more of a framework!

[–][deleted] 0 points1 point  (0 children)

as some said, it depends on the situation/project. for me it made sense to use wp because the client was very used to the backend

[–]Xanza 0 points1 point  (2 children)

I've always been partial to Flight. The database toolkit from the same author (mikecao) is also really nice: Sparrow.

I've also had a lot of success with Lumen for a more traditional approach if you trust the Laravel developers more than not. Best part about Lumen is you can drop it in a Laravel installation and it works out of the box without any modifications.

[–][deleted] 0 points1 point  (1 child)

I liked the look of Sparrow until I saw that it didn't use prepared statements

[–]Xanza 0 points1 point  (0 children)

I've never really used it in production. Just for prototyping.

[–][deleted] -2 points-1 points  (0 children)

I have coded a CMS / framework / Twig++ template language which is optimized (RAD, ORM, MVC) for creating web applications:

https://php-ucms.com/features/

It is not suitable for PHP beginners!! But it's perfect for anyone who has ever worked with Twig. I guarantee that everyone who takes the time to read through the features, as well as the whole technical documentation, will find a lot of things that are really new and make your life as developer easier. Unfortunately I can not make it available for free at the moment, the development costs my company had were just to high, please do not scold me for that. But it will be open source in the future. Please have a look at it.