News Feed
Sections




News Archive
feed this:

Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Rob Allen:
Registering Doctrine Type Mappings for standalone migrations
November 18, 2014 @ 10:50:47

In a previous post Rob Allen showed you how to use Doctrine migrations as a standalone tool in your applications. In this new post he takes that a step further and shows you how to use the type mapping functionality (allowing for more customized column handling).

Shortly after starting to use Doctrine Migrations as a standalone tool in my project, I came across this error message [about an unknown database type "bit"]. This means that I have a column in my database of type bit which is used for booleans in SQL Server, but confuses the MySQL platform as it's not a default mapping. To support this, you need to modify the database connection's Platform object to know about the new mapping. However, with the setup that I'm using, I didn't have access to the connection object that's automatically created in the Migrations AbstractCommand object. After poking around in the code for a bit, I discovered that the solution is to create the connection object myself and then attach it as a new helper to the ConsoleApplication object.

He includes the code you'll need to add to your "migrations.php" file to set up the mapping relating his "bit" type example back to a "boolean" type. While this specific example is for the "bit" mapping, it shows how any mapping type can be added in. Finally he adds the connection (the one he set the type on) to enable it to be included in the helper set collection.

0 comments voice your opinion now!
register type migration doctrine database tutorial custom mapping

Link: http://akrabat.com/php/registering-doctrine-type-mappings-for-standalone-migrations/

Anthony Ferrara:
What's In A Type
October 24, 2014 @ 13:55:39

In a new post to his site Anthony Ferrara takes on the topic of typing in PHP, discussing some of the main ideas around the current typing scheme and the discussions being have about potential changes.

There has been a lot of talk about typing in PHP lately. There are a couple of popular proposals for how to clean up PHP's APIs to be simpler. Most of them involve changing PHP's type system at a very fundamental level. So I thought it would be a good idea to talk about that. What goes into a type?

He starts at the highest level, covering what "typing" is in general and some of the tradeoffs that come with being a strongly typed versus weakly typed language. He then gets into PHP's two "semi-independent type systems" - one for objects and one for everything else. He includes some code examples to illustrate and how, for the non-object handling, context means everything for how the types are switched. He also talks about polymorphism, the chaos that could come from scalars becoming objects and a current RFC suggesting the addition of "safe casting" functions to PHP to provide less "magic" when shifting values from one type to another.

0 comments voice your opinion now!
type switching casting rfc proposal function weak strong

Link: http://blog.ircmaxell.com/2014/10/whats-in-type.html

SitePoint PHP Blog:
Implementing Multi-Language Support
April 16, 2014 @ 12:18:39

The SitePoint PHP blog has a new post from Jacek Barecki talking about a few ways you can include multi-language support in your PHP applications. There's not much in the way of actual code here, but there are links to some other tools that can help get the job done.

Setting up a multilingual site may be a good way to attract new customers to your business or gain more participants in your project. Translating a simple site with a few static pages probably won't probably be complicated, but more complex PHP web applications may require a lot of work when launching multiple language support. In this article I'll present different types of content that need to be taken under consideration when internationalizing a site.

He breaks it down into five different types of content that you might want to translate:

  • Multi-language Static Content
  • Database content
  • User submitted content
  • Resources (images, videos, etc)
  • Other types of content

He wraps it up with a few recommendations including making a checklist of the things you want to translate to figure out what tools you need to use.

0 comments voice your opinion now!
multilanguage support implementation content type

Link: http://www.sitepoint.com/implementing-multi-language-support/

Nikita Popov:
Methods on primitive types in PHP
March 17, 2014 @ 12:11:22

In his latest post Nikita Popov highlights one of the topics from this post, primitive types as objects, and some alternative options.

A few days ago Anthony Ferrara wrote down some thoughts on the future of PHP. I concur with most of his opinions, but not all of them. In this post I'll focus on one particular aspect: Turning primitive types like strings or arrays into "pseudo-objects" by allowing to perform method calls on them. [...] Note that this isn't far off dreaming, but something that already exists right now. The scalar objects PHP extension allows you to define methods for the primitive PHP types. The introduction of method-call support for primitive types comes with a number of advantages.

Among the advantages he lists:

  • The opportunity for a cleaner API (instead of the current, sometimes oddly named functions)
  • Improved readability
  • Polymorphism through a "cleaning up" of shared methods
  • Loose Typing

He also looks at possible ways that other primitive types could be handled (like "null" or "float") and some of the problems that could come up when passing objects around. Since the values could be an object or scalar, how would you know the difference. He finishes off the post with a look at the current state of things, including that there's not much resistance just that there hasn't been a good API defined to make it work.

0 comments voice your opinion now!
method primitive type object example problems

Link: http://nikic.github.io/2014/03/14/Methods-on-primitive-types-in-PHP.html

SitePoint PHP Blog:
HHVM and Hack - Can We Expect Them to Replace PHP?
February 13, 2014 @ 09:29:39

The SitePoint PHP blog has a new post today that asks can we expect HACK and HHVM to replace PHP as an evolution of the PHP language and interpreter.

HHVM is intended to achieve both parity with the Zend Engine features and best possible performances. Facebook claims a 3x to 10x speed boost and 1/2 memory footprint by switching from PHP+APC to HHVM. Of course this is really application dependent (10x being for the FB code base). [...] Instead this article will focus on HACK which is an evolution of the PHP language designed to be safer, to enable better performance and to improve developer efficiency.

He starts off by helping you get an instance of HHVM up and running (via Vagrant) and create a simple HACK script. From there he gets into some of the more advanced HACK features like constructor argument promotion and collections. The talks some about typing, type hinting and the use of generics as well.

0 comments voice your opinion now!
hack hhvm facebook introduction tutorial type collection constructor

Link: http://www.sitepoint.com/hhvm-hack-part-1/

Samantha Quinones:
Juggle Chainsaws, Not Types
November 22, 2013 @ 09:25:33

Samantha Quinones has a new post today about something that has been known to trip up both new and experienced PHP developers - PHP's dynamic type juggling.

No matter how popular an activity it is, I really don't like to bash on PHP. Every language has its flaws when you look closely enough, and if PHP wears its idiosyncrasies a little closer to the surface than most, I think it makes up for it in other ways. PHP's handling of types, however, is confusing at best and at worst completely deranged.

She goes on to talk about the issues with type comparisons and how much trouble using the "==" (double equals) versus the "===" (triple equals) can potentially cause. While it's easier for new PHP developers to get caught by this issue, even experienced devs might miss it. She gives an example of a time in her own development involving the comparison of strings against constants and in_array's non-string type comparisons.

0 comments voice your opinion now!
type juggling strict loose comparison inarray

Link: http://www.tembies.com/2013/11/juggle-chainsaws/

PHPMaster.com:
An Introduction to Ctype Functions
April 30, 2013 @ 11:38:32

On PHPMaster.com today David Shirey has a written up a new tutorial introducing the ctype functions in PHP. This set of functions provides a handy way to more correctly check values to ensure they're valid (and contain what they should).

If you have a background in C, then you're probably already familiar with the character type functions because that is where they come from (don't forget that PHP is actually written in C). But if you're into Python, then it's only fair to point out that the PHP Ctype functions have absolutely nothing to do with the Python's ctypes library. It's just one of those tragic and totally unavoidable naming similarities.

He briefly explains how the functions work and at least one "gotcha" to watch out for if you're using them for input validation. He then goes through the list of the eleven ctype functions and briefly describes what they do. Some example code is also included showing how you can use them to validate a value based on the true/false return from the function call.

0 comments voice your opinion now!
ctype function introduction tutorial character type

Link: http://phpmaster.com/an-introduction-to-ctype-functions

Phil Sturgeon:
Understanding Circumstance
August 22, 2012 @ 10:15:08

Phil Sturgeon has a new post to his site today comparing a few different types of developers and discussing language/tool zealots among them (and a plea for tolerance and understanding).

What is it you do as a developer? As I see it in web dev there are a few different types: Hobbiest, Client Web Dev, Distributed Application Devs, Web App Developer (SaaS) and Corporate Dev. What do they all have in common? They're all using some sort of language to make some sort of system for somebody somewhere. That is about the last connecting factor that most of us developers actually share. [...] The crazy thing here is that most developers who are in a situation where they can use whatever system they like, often end up picking a specific tool and using it to death. This is ridiculous, as every developer should use the best tool for the job.

He talks a bit about each of the different categories of developers and where he sees their place in the world of development. He points out some of the restrictions of each type of position (required technologies, dependencies, etc) and comes to his point about their choices:

The point I am trying to make in all of this, is that while you might have really strong opinions about what language, framework, version of the framework or version of the language you use, EVERYONE has a totally different situation to you.
0 comments voice your opinion now!
opinion developer type restriction technology choice


DZone.com:
The Best Unknown Databases for PHP Apps
August 06, 2012 @ 10:49:50

In this new post to DZone.com today Leigh Shevchik kicks off a series of posts looking at the "unknown databases" that PHP developers might not think about when working on their applications.

In this day and age, there a plethora of options available to us. In this three part series, I'm going to walk you through five alternative databases that you may or may not have heard of. [...] Whether you're involved in embedded development, OLTP, OLAP, massive scalability and storage or simple database-backed applications, you're not going to walk away with the same perspective that you had before you started reading these posts. So without further ado, let's get started with a look at a veteran of the Internet: Berkeley DB.

She covers some of the database's basic features and a bit about its history (available for years) as well as some detail on how requests to the database work. To make the connection from your application, you'll need to install the dba PHP extension. She provides two examples of code that uses the database - one that just connects and deletes a record, another that adds/removes/finds users from an "address book" database.

0 comments voice your opinion now!
database type unknown berkeleydb tutorial dba extension


Community News:
PHP Benchmarks Compared to Several Languages
July 25, 2012 @ 09:14:41

Ariz Jacinto has pointed out some results from a recent benchmarking "game" that compares the performance of several languages against each other in overall speed.

Here's the link to the Computer Language Benchmark Game as of July 15, 2012. You'll see that the median speed of PHP is slightly faster than Python 3 and Ruby 1.9 on x64 Ubuntu/IntelQ6600 Quad-core machine.

You can visit the results page and turn on and off various languages to get the updated results in the chart. You can also limit it down to one of the many benchmarking test types as well.

0 comments voice your opinion now!
benchmark language multiple type chart performance



Community Events





Don't see your event here?
Let us know!


community version symfony list release language tool introduction series laravel composer opinion framework podcast artisanfiles voicesoftheelephpant security conference library interview

All content copyright, 2014 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework