Monthly Archiv: June, 2020

PHP Internals News: Episode 58: Non-Capturing Catches

PHP Internals News: Episode 58: Non-Capturing Catches

In this episode of "PHP Internals News" I chat with Max Semenik (GitHub) about the Non-Capturing Catches RFC that he's worked on, and that's been accepted for PHP 8, as well as about bundling, or not, of extensions.

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. There is a dedicated website: https://phpinternals.news

Transcript

Derick Rethans 0:18

Hi, I'm Derick, and this is PHP internals news, a weekly podcast dedicated to demystifying the development of the PHP language. This is Episode 58. Today I'm talking with Max Semenik about an RFC that is proposed called non capturing catches. Hello Max, would you please introduce yourself.

Max Semenik 0:38

Hi Derick. I'm an open source developer, working mostly on MediaWiki. So that's how I came to be interested in contributing to PHP.

Derick Rethans 0:50

Have you been working with MediaWiki for a long time?

Max Semenik 0:53

Something like 11 years, I guess.

Derick Rethans 0:56

That sounds like a long time to me. The RFC that you've made. What is the problem that is trying to address?

Max Semenik 1:03

In current PHP, you have to specify a variable for exceptions you catch, even if I you don't need to use this variable in your code, and I'm proposing to change it to allow people to just specify an exception type.

Derick Rethans 1:20

At the moment, the way how you catch an exception is by using catch, opening parenthesis, exception class, variable, and you're saying that you don't have to do the name of the variable any more. I get that right?

Max Semenik 1:33

Yes.

Derick Rethans 1:34

Is that pretty much the only change that this is making?

Max Semenik 1:38

Yes, it's a very small, and well defined RFC. I just wanted to do something small, as my start to contributing to PHP.

Derick Rethans 1:51

I'm reading the RFC, it states also that the what used to be an earlier RFC. How does that differ from the one that you've proposed?

Max Semenik 2:00

The previous RFC wanted to also permit a blanket catching of exceptions, as in anything. And that's all, which, understandably, has caused some objections from the PHP community. While most people commented positively on the part that I'm proposing now. Or should I say really propose because the RFC, passed and was merged yesterday.

Derick Rethans 2:35

I had forgotten about it actually, it's good that you reminded me. So yeah, it got merged and ready for PHP eight. Basically what you say you picked the non controversial parts of an early RFC?

Max Semenik 2:47

I actually chose something to contribute and then looked for an RFC, to see if it was discussed previously.

Derick Rethans 2:55

Oh, I see. So, your primary idea of wanting to contribute to PHP, instead of you having an itch that you wanted to scratch, it's like you're saying?

Max Semenik 3:04

I have way larger itches that I will scratch later when I will learn how to work with PHP's code base which, which is really huge.

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

How to Work With Both Good & Bad Design Clients

Today, I want to talk about our favorite subject as designers: clients. Oh, clients. You can’t live with them, you can’t punch them! The primary thing to remember when dealing with clients is this: you can never – I repeat, never – make a bad client into a great client. Let me say that again: you can never make a bad client into a great client.

Sometimes you can make a bad client into a passable one, but, unless you’re getting compensated extremely well, it’s rarely worth the effort.

An unreasonable, demanding, emotionally disturbed client already has those qualities before you even meet them. It’s not personal – they’d most likely be that way with any designer.

If you want to have a challenging yet rewarding, insanity-free working relationship, you must start with a good client.

Fair enough, you say. But how am I supposed to tell which clients are good and which ones aren’t before I work with them?

In my experience, there’s an easy way to determine which clients are worth the trouble and which ones you should just skip over, and it has to do with their budget. Not the specific amount, per se, but their attitude towards budgeting in general.

There’s a profoundly important difference between a reasonable client who doesn’t have much of a budget, and a client who’s just, well, cheap.

The former you should, by all means, seek out and work with – the little guys need good design too! Clients who can’t pay you what you feel your standard rate should be can usually help you out in other ways that will lead to much more lucrative opportunities later. Let me explain what I mean.

Something For Nothing

When working for less than your standard rate (and again, there’s nothing wrong with that, especially in today’s economy), you should always negotiate for something else in exchange for your “discount.”

And you should treat it like a discount. Your client is receiving your services at a lower rate, and they need to be aware that, as such, there are certain deliverables that won’t be available to them.

If your client can’t pay the initial price you quote them for the work, the second price must carry a reduced amount of work. The initial price you quoted them has value in the client’s mind.

If you are willing to “bend” on that price – if you, say, do a job worth several thousand dollars for a few hundred – what happens is that you reduce your perceived value to the client. The client will know then that you weren’t serious about your standard rate, and they may try to take advantage of you and get more work for even less money.

Always be firm about how much you cost. When clients know that you value your work and don’t compromise your own worth by wavering on your prices, they will value your work as well. Just as you wouldn’t expect to get an oil change and new brakes for the price of a car wash, your potential clients must know that there is a limit to how much service you can provide on a budget.

If a client is worth working for, they’ll accept that your higher-priced services are out of their range, and will be willing to discuss other, non-monetary options as part of your compensation. What kind of options? Well, I’ll tell you.

If you’re dealing with a reasonable client, you’ll be able to negotiate for three main forms of non-monetary compensation. You can negotiate for just one, or all three, but using this technique will help you quickly weed out those clients who don’t value you or your work.

The three main elements that can be included in your compensation are:

1. Referrals

Not “exposure” – that’s a vague word which can mean almost anything. But actual, genuine referrals from your client personally to people who can and will hire you. A list of warm leads directly from a paying client is worth its weight in gold, and can sometimes be more valuable than a single paying job.

It’s not too much to ask, and if you’ve got a good client, they should be more than happy to provide at least a few. If not, run far away. That client is not worth the trouble because they aren’t going to get any more reasonable.

If someone can’t be bothered to come up with two or three referrals among their friends or colleagues, what makes you think they’re going to trust your design decisions or resist unnecessary scope creep?

2. Creative Freedom

You can and should use your lack of financial compensation as leverage to secure more creative freedom on a project than you would have otherwise.

This doesn’t mean go berserk with the composition or give them something completely inappropriate. But a client who’s receiving a discounted form of your services can absolutely be expected to hand you the reins and allow you the freedom to make the decisions you feel are best for the project.

3. A Guarantee of Future Paid Work

Whether it’s at your current rate or at a more standard one, your client can offer to provide you with more work in lieu of more money upfront.

Perhaps something more challenging that has a bigger budget, or something recurring that you can deliver on a regular basis. Be creative, and think of all the ways you can provide value to your client.

A good, satisfied client will be happy to give you first priority for future work, if you let them know that you would like it to be part of your compensation. Again, this is not too much to ask for, and any client who thinks it is is a bad client. Period. Runaway.

Never Slave Away for Peanuts

Always make sure to discuss these options with your clients to make sure you’re never just slaving away for peanuts. It goes without saying that, if you expect to receive these kinds of extras, you should do your very best work and provide as much value to your client as possible for the price they’re paying.

No client is going to refer a bad designer to their friends, nor should they be expected to. But if you’re awesome, and you do awesome work, there’s no reason why you shouldn’t expect to be fairly compensated, even if the client is on a budget.

I think that the most important thing a designer can learn is how to be discerning, and how exactly to go about negotiating extras.

There’s an art to it, which many designers, sadly, have not yet mastered. The key is to project confidence and subtly make your clients aware that you have other options without coming off as arrogant, rude, or condescending.

By gently but firmly negotiating extras in your compensation package, you’ll make even the most budget-conscious clients respect you and desire to work with someone of your performance level.

And the “cheap” clients who won’t budge? Leave ’em – they’re impossible conversions!

The post How to Work With Both Good & Bad Design Clients appeared first on Speckyboy Design Magazine.

Community News: Latest PECL Releases (06.16.2020)

Latest PECL Releases:

  • pcs 1.3.7
    * Fix Travis Ci failures

  • pcs 1.3.5
    * Fix issues in PHP 7.4
  • pcs 1.3.4
    * Fix issue #12 : Fails to install in PHP 7.4.6
  • yaf 3.2.5
    - Fixed issue #492 (init method could be protected) - Fixed issue #492 (plugins maybe changed in controller execution) - Fixed issue #492 (empty names shoud not be set to request) - Fixed cow_violation conflicts
  • mongodb 1.8.0beta2
    ** Bug * [PHPC-1598] - Objects with get_properties handlers should have get_gc delegate to zend_std_get_properties

    ** New Feature * [PHPC-1313] - Add support for Zstandard compression * [PHPC-1533] - OCSP Support * [PHPC-1554] - Unify behavior around configuration for replica set discovery * [PHPC-1571] - Driver support for server Hedged Reads * [PHPC-1575] - Add URI option to disable certificate revocation checking

    ** Task * [PHPC-1131] - Do not compile php.exe for Appveyor builds * [PHPC-1384] - Specify behavior where connection string contain auth database but no credentials * [PHPC-1616] - Remove PHP 7.1 from AppVeyor build config * [PHPC-1621] - Bundled libmongocrypt emits compiler warning

    ** Improvement * [PHPC-1566] - Support speculative authentication attempts in isMaster * [PHPC-1591] - Add tests for allowed cases when authSource is given but username is not * [PHPC-1614] - Consult SIZEOF_ZEND_LONG instead of SIZEOF_LONG * [PHPC-1615] - Specify obj_dir when adding sources in config.w32 * [PHPC-1628] - Clarify return type for WriteConcernError and WriteError getInfo() methods * [PHPC-1629] - Call libmongoc is_valid functions before completing WriteConcern and ReadPreference initialization * [PHPC-1632] - Reduce default keepalive time to align with Azure defaults

How CSS Variables Can Improve Efficiency and Consistency

Code repetition is one of the more frustrating aspects of CSS. Having to type out the same property values over and over throughout a stylesheet takes time. And when making changes down the road, it’s too easy to miss a value.

The result is an inconsistent design. Things like colors, animation speed and element spacing can vary – simply because a designer didn’t catch every instance. Thus, the user experience is thrown out of whack.

CSS variables (a.k.a. Custom Properties) are a great way to combat these issues. Yet, not all designers know about this simple technique. Today, we’ll take you on a quick tour of what they are and what they do. Let’s dig in!

Set a Value Once, Use It All Over

Those who are familiar with programming languages such as PHP and JavaScript may recognize the term “variable”. A variable sets a value (static or dynamic) that can be retrieved later on in a script. For instance, a PHP variable called $user_first_name might be utilized to fetch a logged-in user’s first name to display on a page.

Similarly, CSS variables are there to repeat a value throughout a stylesheet. At bare minimum, this saves us from typing in a font family or hex color code multiple times.

You may also recognize variables from CSS preprocessors like Sass. There, variables serve essentially the same purpose (although the syntax is indeed different). However, they are not native to CSS. That means the preprocessor has to convert a variable into valid CSS.

CSS variables are a native solution. They’ll save you from having to use a preprocessor, unless you really want to. Now, any stylesheet can take advantage of this handy feature.

And you shouldn’t have to worry about browser support – with a caveat. Every modern browser has supported CSS variables for quite some time. But if you’re still targeting Internet Explorer users, a fallback will be required. That is a consideration, but everyone else is good to go.

A Basic Example of a CSS Variable

Color is one of the properties that often gets repeated throughout a stylesheet. For instance, you might use the same color for specific headings, container backgrounds, buttons and more. Using a CSS variable here makes the task of assigning and changing a value much more efficient.

Let’s use the iconic blue color of Speckyboy as an example. First, we’ll set up a variable in our stylesheet:

:root {
--speckyboy-blue: #4F78A4;
}

The variable name, --speckyboy-blue, is set to a hex color code. From there, it’s a matter of calling the variable for each and every instance where we want to use this pretty shade of blue.

If we wanted to use this as a text color on an element in our stylesheet, the syntax would look like this:

color: var(--speckyboy-blue);

The following example shows how the variable can be used in multiple places. For good measure, we also threw in another variable for our top and bottom margin value to keep spacing consistent throughout our design.

See the Pen
Basic CSS Variable
by Eric Karkovack

Future changes will now be much easier as well. Because of the CSS variables in the above snippet, we now only have to change the hex color of --speckyboy-blue or the pixel value of --vmargin. Those values will cascade down to every instance in our stylesheet.

CSS Variable Resources

Our example only scratches the surface of what is possible with CSS variables. It’s worth digging a little deeper to see how it can be used in more advanced scenarios. The resources below are a great place to learn more:

The post How CSS Variables Can Improve Efficiency and Consistency appeared first on Speckyboy Design Magazine.

Book release: PHP for the Web

Book cover

While Advanced Web Application Architecture is still a work in progress, I decided to release another project in the meantime: a book for beginning PHP developers called PHP for the Web.

Of course, there are PHP books for beginners, but most of them aren't very concise. They cover many related topics like relational databases, CLI applications, and sending emails. I wanted to write a book that only shows what makes PHP so special when it comes to web development.

Writing this book took me back to the beginning of my own programming career in 2002. Many things have changed since then, but surprisingly many things are still the same too!

The biggest change when it comes to dealing with the web in PHP: we now have frameworks. This is obviously a good thing, since it has made our applications much more secure. For instance, in 2002 I wasn't aware of the need for output escaping, or to escape parameters in my SQL queries, and I didn't know that I should protect TinyMCE's upload script against anonymous file uploads...

On the other hand frameworks hide so many of the lower-level details that I dare to say that many PHP developers today don't know how it all works under the hood. What are cookies and how do they work? What's the difference between PHP errors and exceptions? What is $_FILES and how can I use it?

This new book, PHP for the Web explains it all in over 200 pages.

If you're thinking about learning PHP to build web applications, use the following link to get the book for just $9: https://leanpub.com/learning-php-for-the-web-without-a-framework/c/RELEASE_DAY And if you know someone who thinks about learning PHP, forward this link to them as well!

Here's the table of contents to give you an idea of what's in there. If you want to read a sample, go to the landing page and click on Read Free Sample.

  1. Serving resources
    • Serving an index.html file with the built-in web server
    • The project root should not be the document root
    • Communication between the browser and the server
  2. Serving PHP scripts
    • The response: status, headers and body
    • Linking to other pages
    • Passing values between requests
    • user input can’t be trusted
  3. Forms
    • Submitting form data as query parameters
    • Always use output escaping
    • Adding a select element to the form
    • Submitting data via the request body
  4. Cookies
    • Setting a cookie
    • Using a cookie
    • Redirecting after processing a POST request
  5. Sessions
    • Session files and serialized data
    • Flash messages
    • Using flash messages everywhere
  6. Authentication
    • Setting up a login form
    • Logging out
  7. Project structure
    • Header and footer snippets
    • Bootstrapping
    • Routing
  8. CRUD part 1: Create
    • Saving JSON-encoded data in a file
    • Adding a tour
    • Form validation
    • Listing tours
  9. CRUD part 2: The rest
    • Introducing some reusable elements
    • Editing tour data
    • Deleting tours
  10. File uploads
    • Uploading a file
    • Showing the uploaded picture
    • Form validation for file uploads
  11. Error handling
    • Producing an error
    • Using different configuration settings in production
    • PHP errors
  12. Automated testing
    • Using Composer to install testing tools
    • Creating our first browser test
    • Starting with a clean slate
  13. Conclusion

Now go get your copy!

Cognitive PHP Voice Recognition

Package:
Cognitive PHP Voice Recognition
Summary:
Recognize voices in audio with Microsoft Azure API
Groups:
Artificial intelligence, Audio, PHP 5, Web services
Author:
uche
Description:
This package can Recognize voices in audio with Microsoft Azure API...

Read more at https://www.phpclasses.org/package/11683-PHP-Recognize-voices-in-audio-with-Microsoft-Azure-API.html#2020-06-15-10:41:05
Powered by Gewgley