Hey! 👋

Whether you’re an experienced PHP developer, a beginner just starting your journey, or an enthusiast interested in understanding more about the world of PHP, this is the place for you. We are a community dedicated to sharing knowledge, discussing new trends, and solving problems related to PHP.

As members of this community, we expect everyone to respect each other and foster a positive environment. Please make sure your posts are relevant to PHP, and remember to be kind and considerate in your discussions. Let’s learn from each other and help each other grow.

Whether you’re here to ask questions or to share your knowledge, we’re excited to have you here. Let’s make the most of this community together!

Welcome to /c/php! 🐘

  • dbx12
    link
    fedilink
    41 year ago

    Hey, I’ve came over from Reddit and thought I’ll introduce myself as well. As every programmer, I’ve started way too many pet projects and almost all of them are starving. In terms of framework, I prefer Yii2 over Laravel every day. I feel like Laravel provides you a dozen different (seemingly equally good) ways of doing something. You could say it’s lacking clarity or guidance for the developer.

    • @[email protected]OPM
      link
      fedilink
      11 year ago

      Hey, welcome! Classic haha, I have far too many pet projects as well 😅

      And yeah agreed, it’s a bit dizzying to choose a Laravel “path”. Would probably be helpful to have a documentation page sort of like the Remix Stacks where they talk a little bit about which “path” to choose depending on app needs.

      • dbx12
        link
        fedilink
        11 year ago

        Docs is another topic I really don’t like about Laravel. Why don’t you have a simple API doc with available functions and their parameters instead of that blog-style documentation. And no, I don’t want to watch a video about how to use X, I want to know what functions I can call. Oh and don’t get me started on all their global “helper” functions.

        • @[email protected]
          link
          fedilink
          31 year ago

          This is not a comment trying to convert you to Laravel, but if you or anyone else is interested, an API doc actually exists and is available here.

          • dbx12
            link
            fedilink
            11 year ago

            I really appreciate that, thank you. I sometimes have to work with an existing Laravel project at work and this is the kind of documentation I was looking for. Short, to the point, without blabbering.

  • @[email protected]
    link
    fedilink
    21 year ago

    Hey there! I am new here (migrating from Reddit). Full-stack developer (about 7 years). I hope you’re all having a great day.

  • @[email protected]
    link
    fedilink
    1
    edit-2
    1 year ago

    Hello, and thanks for creating this community! Sorry if I make grammar mistakes, I’m not a native speaker.

    I am a developer who has been working with PHP for a few years now, but I still consider myself a beginner because I’m the sole developer on my company and I have to learn and do all by myself and take all the development decisions. I’m actually relearning PHP and Laravel following more “formal” courses to cover all the bases that I’m surely lacking and then I’m planning to look for a job when I can work as part of a team to learn from other developers.

    Speaking about Laravel, I was looking through the fediverse for a Laravel community, as it was a different subreddit from the PHP one on Reddit. But being a small community for now, maybe it’s a good idea to keep everything together while the community starts growing? What do you think?

    • @[email protected]OPM
      link
      fedilink
      21 year ago

      Solo dev? That’s a huge undertaking, especially having to learn by yourself! I think Laravel and Laracasts are excellent starting point to learn “good” PHP and it will definitely open up doors for your next job.

      And yes definitely, I think there could be a Laravel specific community!

  • SALT
    link
    fedilink
    English
    11 year ago

    Seems between instance, the old comment isn’t synced… ugh…

  • @[email protected]
    link
    fedilink
    11 year ago

    Can anyone here help me understand persistent PDO connections?

    So I set up Patroni cluster, everything works as expected. But during the failover/switchover PHP remembers connections to the failed node. And I can’t figure out why. Reloading FPM is kind of PitA.

    I will use PgBouncer. But I still would like to know how PHP works with the persistent connections.

    • @[email protected]
      link
      fedilink
      21 year ago

      I haven’t used persistent connections although I have been tempted in the past. I believe, if you haven’t used it before, it might come with more trouble than it solves.

      As an alternative I could propose using amphp (or maybe react PHP) which will let you handle a pool of connections in a single long running process. But it’s a bigger change really, the more I think of it.

      • @[email protected]
        link
        fedilink
        11 year ago

        Yeah, but any ‘single server’ PHP defeats the purpose of PHP, so I’m not a huge fan.

        I’ve used them in the past, and they work great, until you have to switchover to another node.

        • @[email protected]
          link
          fedilink
          11 year ago

          Fair point.

          However why do you need persistent connections ? I am thinking that the growing rate of the connections should be very low as the instances increase, given that the queries are quick.

          • @[email protected]
            link
            fedilink
            11 year ago

            You lose about 5-6ms just connecting to the database. Keeping them open helps a lot.

            My goal is to write as simple code as possible, and everything else is super quick, just the connections aren’t handled well in PHP. Which is a shame.

            • @[email protected]
              link
              fedilink
              11 year ago

              It’s not that there isn’t the option, it’s just that I don’t know how to help you. MySQL has an option to reconnect, I suppose might be the same for postgres?

              The single running process that was so easily dismissed, could save tons of queries, for example! Sorry I keep thinking about that direction

              • @[email protected]
                link
                fedilink
                11 year ago

                Single process doesn’t save any queries, no idea what you mean.

                Persistent connections persist between requests just like in a single process. It’s just that pool handling is hidden in PDO.

                • @[email protected]
                  link
                  fedilink
                  11 year ago

                  Also how’s the setup? You setup for example 5 max children in fpm and 5 persistent connections? Per server? So your overall connections to the db server will be 5x your server instances?

                  If you setup 5 fpm children and less connections, one child will eventually reuse from another, but only when the connection is free (does not do a query for another process or pdo does not consume a resultset). If it tries to do a query at that time it will have to wait and it will block. This is my understanding. Also how you do transactions with persistent connections?

                  This has evolved into such an interesting conversation.

              • @[email protected]
                link
                fedilink
                11 year ago

                Also, to work with persistent connections you will have to have a pool right? Because when you query from instance 1, the connection is not available until you consume the result set. Or is that only for MySQL?

                • @[email protected]
                  link
                  fedilink
                  11 year ago

                  Yes, you have a pool, but it’s handled by PDO somewhere, and I have no idea how to manipulate it. It just occured to me to try to open another resource before deallocating the first one.

                  If that doesn’t work, I will give PgBouncer a try. In case that won’t do what I need, I’ll just use pg_pconnect.

                  I love PHP so much, this is one of two issues I have with it.

    • @[email protected]OPM
      link
      fedilink
      11 year ago

      Honestly I don’t know much about this but I think this can occur because PHP (or more specifically, the PDO extension) isn’t necessarily aware of the health of the PostgreSQL node it’s connected to. From PHP’s perspective, it opened a connection, and unless explicitly told otherwise, it will assume the connection remains open. The Patroni switchover/failover is happening independently of PHP. PgBouncer is probably a good solution for this.

  • @Skyzyx
    link
    11 year ago

    My name is Ryan Parman. The most popular (public) projects I’ve created are SimplePie (RSS), and I brought Tarzan/CloudFusion with me to Amazon to create the AWS SDK for PHP. I care a lot about performance, code quality, and standardization.

    These days I don’t write much PHP anymore (mostly Golang, Python, Bash, and Terraform now), but I love to stay up-to-date with the community and improvements in the language.