PHP Scripts – Web Development BlogHow to validate the email address format in PHP? (22.4.2019, 15:00 UTC)

Receiving email messages via your website or web application is an important feature and often the only way to get in contact with your customers. If you look back, how often have you got an email message from a potential customer with an invalid or wrong email address? Sure you can use advanced regular expression […]

Originally published by Web Development Blog

Link
Anthony FerraraA PHP Compiler, aka The FFI Rabbit Hole (22.4.2019, 04:00 UTC)

It’s no secret that I’m into building toy compilers and programming languages. Today I’m introducing something that’s not a toy (I hope). Today, I’m introducing php-compiler (among many other projects). My hope is that these projects will grow from experimental status into fully production ready systems.

JIT? AOT? VM? What The Heck?

Since I’m going to be talking a lot about compilers and components in this post, I figure it’s good to start with a primer on how they work, and how the different types behave.

Types of Compilers

Let’s start by talking about the 3 main categories of how programs are executed. (There are definitely some blurred lines here, and you’ll hear people using these labels to refer to multiple different things, but for the purposes of this post):

  • Interpreted: The vast majority of dynamic languages use a Virtual Machine of some sort. PHP, Python (CPython), Ruby, and many others may be interpreted using a Virtual Machine.

    A VM is - at its most abstract level - is a giant switch statement inside of a loop. The language parses and compiles the source code into a form of Intermediary Representation often called Opcodes or ByteCode.

    The prime advantage of a VM is that it’s simpler to build for dynamic languages, and removes the “waiting for code to compile” step.

  • Compiled: The vast majority of what we think of as static languages are “Ahead Of Time” (AOT) Compiled directly to native machine code. C, Go, Rust, and many many others use an AOT compiler.

    AOT basically means that the full compilation process happens as a whole, ahead of when you want to run the code. So you compile it, and then some time later you can execute it.

    The prime advantage of AOT compilation is that it can generate very efficient code. The (prime) downside is that it can take a long time to compile code.

  • Just In Time (JIT): JIT is a relatively recently popularized method to get the best of both worlds (VM and AOT). Lua, Java, JavaScript, Python (via PyPy), HHVM, PHP 8, and many others use a JIT compiler.

    A JIT is basically just a combination of a VM and an AOT compiler. Instead of compiling the full program at once, it instead runs the code on a Virtual Machine for a while. It does this for two reasons: to figure out which parts of the code are “hot” (and hence most useful to be in machine code), and to collect some runtime information about the code (what types are commonly used, etc). Then, it pauses execution for a moment to compile just that small bit of code to machine code before resuming execution. A JIT runtime will bounce back and forth between interpreted code and native compiled code.

    The prime advantage of JIT compilation is that it balances the fast deployment cycle of a VM with the potential for AOT-like performance for some use-cases. But it is also insanely complicated since you’re building 2 full compilers, and an interface between them.

Another way of saying this, is that an Interpreter runs code, whereas an AOT compiler generates machine code which then the Computer runs. And a JIT compiler runs the code but every once in a while translates some of the running code into machine code, and then executes it.

Some more definitions

I just used the word “Compiler” a lot (along with a ton of other words), but each of these words have many different meanings, so it’s worth talking a bit about that:

  • Compiler: The meaning of “Compiler” changes depending on what you’re talking about:

    When you’re talking about building language runtimes (aka: compilers), a Compiler is a program that translates code from one language into another with different semantics (there’s a conversion step, it isn’t just a representation). It could be from PHP to Opcode, it could be from C to an Intermediary Representation. It could be from Assembly to Machine Code, it could be from a regular expression to machine code. Yes, PHP 7.0 includes a compiler to compile from PHP source code to Opcodes.

    When you’re talking about using language runtimes (aka: compilers), a Compiler is usually implied to be a specific set of programs that convert the original source code into machine code. It’s worth noting that a “Compiler” (like gcc for example) is normally made up of several smaller compilers th

Truncated by Planet PHP, read more at the original (another 77750 bytes)

Link
Voices of the ElePHPantInterview with Andrew Caya (18.4.2019, 11:00 UTC)

This episode is sponsored by

The post Interview with Andrew Caya appeared first on Voices of the ElePHPant.

Link
Derick RethansPHP Internals News: Episode 6: PHP Quality Assurance (18.4.2019, 08:06 UTC)

PHP Internals News: Episode 6: PHP Quality Assurance

In this sixth episode of "PHP Internals News" we talk to Remi Collet (Twitter, Website, GitHub, Donate) about the work that he does through RedHat and Fedora to improve the quality of PHP, PHP extensions, and PHP libraries and frameworks.

The RSS feed for this podcast is https://derickrethans.nl/feed-phpinternalsnews.xml, you can download this episode's MP3 file, and it's available on Spotify and iTunes.

Show Notes

Credits

Music: Chipper Doodle v2 — Kevin MacLeod (incompetech.com) — Creative Commons: By Attribution 3.0

Become a Patron!
Link
larry@garfieldtech.comPSR-14: Example - plugin registration (17.4.2019, 23:08 UTC)
PSR-14: Example - plugin registration

In Content Management Systems and similar highly-configurable applications, a common pattern is to have a registration mechanism of some sort. That is, some part of the system asks other parts of the system "give me a list of your Things!", and then modules/extensions/plugins (whatever the system calls them) can incrementally build up that list of Things, which the caller then does something with. Those Things can be defined by the extension, or they can be defined by user-configuration and turned into a Thing definition by the module. Both are valid and useful, and can be mixed and matched.

This pattern lends itself very well to an Event system like PSR-14, and in fact the "give me a list of Things" pattern was one of the explicit use cases the Working Group considered. Today let's look at how one could easily implement such a mechanism.

Continue reading this post on SteemIt.

Larry 17 April 2019 - 6:08pm
Link
Matthew Weier O'PhinneyFrom Zend Framework To The Laminas Project (17.4.2019, 16:58 UTC)

Ten years ago this month, I was involved in a couple of huge changes for Zend Framework.

First, I helped spearhead integration of the JavaScript library Dojo Toolkit into Zend Framework, and finalized the work that month. I'd worked closely with the two developers who had been leading that project at the time, and one thing that came up during our discussions was that they had helped create an open source foundation for the project, to ensure its continuity and longevity, and to ensure the project can outlive the ups and downs of any commercial company. This idea intrigued me, and has stuck in the back of my mind ever since.

The other thing that happened that month was that I was promoted to Project Lead of Zend Framework. I've held that position ever since.

Today, I get to announce another change: Zend Framework is transitioning to an open source project under the Linux Foundation!

How Zend Framework Becomes Laminas

As I noted, I've been thinking about this for 10 years now, and actually doing research and trying to figure out a way to make it happen for almost two years. When my employer announced some restructuring of the Zend portfolio last fall, moving the project to a foundation was foremost on my mind.

So, imagine my surprise when an old PHP friend, John Mertic, reached out to me and offered the assistance of the Linux Foundation!

I had no idea that this was even a possibility. But, as it turns out, the mission of the foundation is to help create sustainable open source communities, and the primary way they do that is to help create foundations for projects. The beauty is that they take care of the business stuff that developers like myself don't have expertise in: legal issues, taxes, bookkeeping, and even help with things like marketing. They do this so that those of us working on open source projects can focus on our communities and our code. It's an absolutely perfect scenario for the project.

Over the last few months, I've worked with Rogue Wave (my employer) and the Linux Foundation to work out the logistics of this transition, including coming up with some initial budgets, helping flesh out a governance model, and identifying potential founding members. I've also worked with the Zend Framework community review team to come up with a name for the project, and work out some of the technical details for migrating both the project and its users.

So, please say a warm hello to the Laminas Project.

Laminas Project

What we announced today is just a beginning. The project is not yet operational. We're still working on tooling for migrating the project and its users, and, more importantly, recruiting more founding members. If your company is interested, please fill out our form, and we'll get back to you to discuss the details.

Acknowledgments

As a parting note, I need to acknowledge a number of people who helped me through the last few months:

  • My wife, Jen, who has been my chief sounding board, and helped me keep my sanity while I juggle meetings, emails, and growing task lists. Love you!
  • Enrico Zimuel, who has been my co-worker, confidante, and friend for years, and continued to help even when he left Rogue Wave last month. I'm excited for this new chapter!
  • The various folks in the Zend Professional Services team, for letting me bounce ideas off of them and occasionally voice my frustrations. You all know who you are!
  • The entire Zend Framework community review team: Rob, Gary, Marco, Frank, James, Evan, Adam, Aleksei, Andreas, Ben, Geert, Ryan, Michał, Michael, and Mike (yes, those last three are all different people!). In particular, Michał has been putting in crazy hours working on migration tooling, and Frank just this morning sent over changes for the Laminas website for me to incorporate!
  • John Mertic and Michael Dolan of the Linux Foundation for holding my hand through this entire process and helping make it happen. We still have work to do, but even getting this far feels like a huge accomplishment, and I couldn't have done it without your support.

If all goes to plan, I'm hoping we'll be announcing the project is operational in the next few months; keep an eye on the ZF and Laminas websites and twitter handles for updates!

mwopFrom Zend Framework To The Laminas Project was originally published 17 April 2019 on https://mwop.net by .
Link
Adam CulpZend Framework becomes Laminas project (17.4.2019, 14:16 UTC)

Today it was announced that Zend Framework is being rebranded as Laminas project. (drawn from the meaning “a thin layer”) Along with the rebrand comes some other important changes as well. Yes, this includes Expressive and Apigility, so continue reading.

Some History

Zend Framework is one of the largest and oldest PHP frameworks and has become a staple for enterprise development around the world. As of April 2019, it has over 400 million lifetime downloads of all packages associated with the project, which has seen a 4-fold increase in just the last 2 years alone. Despite this amazing track record, up to now the project has been supported and guided single-handedly by Zend Technologies, and later Rogue Wave Software.

Awesome Changes

Therefore, to continue this growth and receive the best support possible, the Zend Framework team is announcing that all projects under that umbrella will rebrand to a newly formed “Laminas” project“, which aims to continue their mission as an open source project hosted by the Linux Foundation. The transition will enable more companies to provide support for the projects they’ve come to depend on and help it continue to grow. As part of this transition, it is important for them to differentiate the open source project from the Zend commercial brand. Therefore, the new name “Laminas” project was created.

As part of this move, the Expressive microframework, Apigility api framework, as well as the MVC framework will all be part of the Laminas project.

I will try to add more details as they become available to us all, and will likely also do a Twitch stream and YouTube video with Beachcasts and that video can be viewed HERE.

Support Laminas Project

For more information, please see the new site dedicated to the Laminas project, and if you would like to become a member and/or support the project at the Linux Foundation (their blog post), please join and become a member.

Impact to current users

The framework team is working on scripts and tools to help users update namespaces and vendor packages with the renaming. See the video below for more info.

Beachcasts Video

I added this, and a little more content about the Zend Framework rebranding to Laminas project under the Linux Foundation. Check it out below.

Link
Adam Culp10 bad things about consulting, and why it might not be for you (16.4.2019, 15:01 UTC)

In this video I share 10 bad things about being a consultant, and why a consulting job might not be a good fit for you. Adam Culp of Beachcasts shares points from his experience to help you figure out if being a PHP consultant is the right job for you.

Or you can view this video on YouTube at: https://youtu.be/ELE0G3e7h3c

Link
Evert Pot421 Misdirected Request (16.4.2019, 15:00 UTC)

A server should emit 421 Misdirected Request when it receives a HTTP request that was not intended for that server.

This status was introduced with HTTP/2, but it may also be applicable to HTTP/1 servers. For example, a server might receive the following HTTP request:

GET /contact.html HTTP/1.1
Host: foo.example.org

Since HTTP/1.1 a client is required to include a Host header. A server might already know that the foo.example.org domain is not configured on that server, cand could respond with a 421 Misdirected Request response to tell the client that it connected to the wrong server:

HTTP/1.1 421 Misdirected Request
Content-Type: text/html

<h1>Switchboard operator error</h1>

So when can that actually happen? One example of this is that the DNS for a server was set to the wrong IP or CNAME, or simply a server configuration error.

HTTP/2

There’s other examples where this might occur. In HTTP/2 it will be possible for a single HTTP/2 connection to be used for multiple domainnames via connection coalescing.

If a client is trying to use this feature but a server doesn’t support it, it must return 421 Misdirected Request This is actually the real reason this status got introduced.

References

Link
Voices of the ElePHPantInterview with Susan Ibach (16.4.2019, 11:00 UTC)

This episode is sponsored by

The post Interview with Susan Ibach appeared first on Voices of the ElePHPant.

Link
LinksRSS 0.92   RDF 1.
Atom Feed   100% Popoon
PHP5 powered   PEAR
ButtonsPlanet PHP   Planet PHP
Planet PHP