Announcement

Collapse
No announcement yet.

PHP 8.4 Released With Property Hooks, Lazy Objects & Other New Features

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • #21
    Originally posted by Jonjolt View Post

    I'm using jlink in production, lol one of the best features is just renaming the executable instead of trying to track down which process is which.
    Ok that's nice. Previously 'killall java' killed all Java apps? I've noticed that IDEA doesn't use that executable name anymore but I thought they had customized their JDK somehow.

    Comment


    • #22
      Originally posted by caligula View Post

      Ok that's nice. Previously 'killall java' killed all Java apps? I've noticed that IDEA doesn't use that executable name anymore but I thought they had customized their JDK somehow.
      They probably use a launcher, jpackage can make a custom launcher but it doesn't expose a lot of configuration options and is more desktop oriented, basically when you see a JVM app without a console under Windows they are using a custom launcher. Literally it is native code that starts up the JVM

      Sources here for jpackage https://github.com/openjdk/jdk/tree/...c/jdk.jpackage

      Comment


      • #23
        Originally posted by uid313 View Post
        Yes, exactly, I would have an RESTful endpoint so I know how to deserialize based on the name of the endpoint which is in the URI, so for example I would have the HTTP endpoint /api/pets/ which accepts GET and POST requests, and I would have /api/pets/{id} which accepts GET, PUT and DELETE requests so when a client does a POST request against the pet endpoint I know that I should attempt to deserialize the request body into a Pet object which would be an instance of the Pet class. If the deserialization would fail I would return the HTTP status code 400 Bad Request.
        Sounds like you want Laravel Route Model Binding + Laravel Form Requests (maybe even API Resources). Pretty simple stuff, and as always there a packages to make it even simpler.

        Comment


        • #24
          Originally posted by murraytony View Post

          Sounds like you want Laravel Route Model Binding + Laravel Form Requests (maybe even API Resources). Pretty simple stuff, and as always there a packages to make it even simpler.
          Yeah, probably Laravel can do this, and probably Laravel is a great framework, but I really wish PHP had great support for JSON and a great HTTP client out-of-the-box.

          Comment


          • #25
            Originally posted by uid313 View Post
            A very good update with lots of new great improvements. Personally I think the new asymmetric visibility thing is confusing.

            I think that the syntax for property hooks is a bit verbose since you have to repeat the data type and the variable name, this is much cleaner in C#.

            I would like to see PHP support for expression-bodied functions like they have in C# so that you can write a function on one line with => arrow and skip the return keyword.

            I think PHP have some problems:
            • JSON support is very poor, you can only serialize to stdClass or an associated array, not to your own classes so you don't have type safety, and you cant override property names if you want to serialize a kebab-case JSON into a camelCase property.
            • There is no support for UUID (I know there are third-party libraries available, but I think it should be in the standard library).
            • HTTP support is very poor, you have to use the very awkward libcurl, I would like to see a modern HTTP request support in the standard library, like the Fetch API in JavaScript, the HttpClient class in .NET, or the requests/httpx library in Python.
            I agree with you about needing a more ergonomic HTTP client. Guzzle and the like are fine and all, but it's exactly the sort of niche the standard library ought to fill—especially since we're already most of the way there with stream wrappers. It just needs to have a proper API.

            As for UUIDs, as someone who wrote one such third-party library, it would be nice, but I haven't had it come up much.

            I'm baffled about your complaints over JSON, though. You'd need a lot of plumbing to map JSON to arbitrary classes, wouldn't you? Does anything do that?

            Comment


            • #26
              Originally posted by J.King View Post
              I agree with you about needing a more ergonomic HTTP client. Guzzle and the like are fine and all, but it's exactly the sort of niche the standard library ought to fill—especially since we're already most of the way there with stream wrappers. It just needs to have a proper API.

              As for UUIDs, as someone who wrote one such third-party library, it would be nice, but I haven't had it come up much.

              I'm baffled about your complaints over JSON, though. You'd need a lot of plumbing to map JSON to arbitrary classes, wouldn't you? Does anything do that?
              in .NET you use the JsonSerializer class in the System.Text.Json namespace and you use generics to specify the class and pass it a string as argument then it deserialize and return a instance of that class you specified where each key in the JSON is mapped to a property in the class. It is very nice and you can give the function an option class so you can configure if you want to serialize from camelCase or PascalCase or kebab-case, or under_score. If you want you can put attributes on the properties if the name of your property in your class is different from the key in the JSON. You can also do polymorphic JSON so you can have many different classes each with different properties and which class it uses depends on the type discriminator which is a key which defines what type of object it is, so it is great for JSON-LD too.

              I am sure Java have powerful JSON too. The serde-json library in Rust was alright too. In my experience JSON have been the poorest in PHP and Python.

              Comment

              Working...
              X