News Feed
Jobs Feed
Sections




News Archive
feed this:

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

NetTuts.com:
Reflection in PHP
April 19, 2013 @ 10:24:28

On NetTuts.com today there's a new tutorial talking about a part of PHP that can be quite powerful but isn't used too often - reflection in PHP. Using Reflection you can get information about your actual code and its elements without having to try to parse it yourself.

Reflection is generally defined as a program's ability to inspect itself and modify its logic at execution time. In less technical terms, reflection is asking an object to tell you about its properties and methods, and altering those members (even private ones). In this lesson, we'll dig into how this is accomplished, and when it might prove useful.

They provide a little context around the idea of "reflection" in programming languages and then jump right in with a few sample classes. They set up their "Nettuts", "Manager" and "Editor" classes and show how to use the ReflectionClass functionality to get their structure. The examples show how to get the class' methods, their properties and calling these methods using things like invoke and call_user_func.

0 comments voice your opinion now!
reflection tutorial introspection methods parameters invoke

Link: http://net.tutsplus.com/tutorials/php/reflection-in-php

PHPMaster.com:
Introspection and Reflection in PHP
May 25, 2012 @ 14:03:57

On PHPMaster.com today there's an introduction to Reflection, a feature of PHP that allows you to peer into the code itself and find out metadata like class properties, scope levels and parent classes.

PHP introspection is a common feature in any programming language which allows object classes to be manipulated by the programmer. You'll find introspection particularly useful when you don't know which class or method you need to execute at design time. [...] During this article, you'll see a couple examples of how to use some of the most useful PHP's introspection function and a section dedicated to an API that offers functionality similar to introspection, the Reflection API.

They introduce you to a few different methods including class_exists, get_class and get_class_vars and method_exists. They also briefly mention the "ReflectionClass" that's a part of the PHP Reflection API and how it can be used to make an instance pointing to a current class.

0 comments voice your opinion now!
introspection reflection tutorial api metadata


Maarten Balliauw's Blog:
A client side Glimpse to your PHP application
August 03, 2011 @ 11:28:54

Maarten Balliauw has announced the release of a PHP port of a powerful tool for server-side introspection of your applications - Glimpse for PHP.

A few months ago, the .NET world was surprised with a magnificent tool called "Glimpse". Today I'm pleased to release a first draft of a PHP version for Glimpse! Now what is this Glimpse thing Well: "what Firebug is for the client, Glimpse does for the server... in other words, a client side Glimpse into whats going on in your server."

He includes a of how the introspection works and some sample code using a phar to add it to your PHP application. You can see it in action in this screencast based on the PHP Azure Contest website. He also shows one very cool feature that allows for cross-device tracking of requests. You can find this PHP port of Glimpse on github.

2 comments voice your opinion now!
glimpse port introspection phar server plugin client


Elated.com:
Object-Oriented PHP Autoloading, Serializing, and Querying Objects
July 01, 2011 @ 08:29:45

On Elated.com today there's the fourth part of their series looking at object oriented programming in PHP. This time the focus is specifically on autoloading classes, making objects into strings (serialized) and introspection.

If you've read all the articles up to this point then you're already familiar with the most important concepts of object-oriented programming in PHP: classes, objects, properties, methods, and inheritance. In this final (for now, at least!) tutorial in the series, I'm going to tie up some loose ends and look at some other useful OOP-related features of PHP.

He looks at each of the three topics above and includes code for things like a simple autoloader, object serialization, using sleep/wakeup and an example of using functions like get_class, get_class_methods and get_object_vars to do introspection on your classes and objects.

0 comments voice your opinion now!
oop tutorial class object autoload serialize introspection


Alexey Zakhlestins' Blog:
GObject for PHP (new bindings project)
February 24, 2011 @ 08:25:23

In a new post Alexey Zakhlestins talks about a project he's been working on, a part of the split up with PHP-GTK out into separate projects. His part of the group is GObject with has now been moved over to github.

This new PHP extension is called "GObject for PHP", so, my main concern, obviously is building comfortable bridge between GObject objects and PHP's objects. It starts to work, but there's a lot of stuff to be done. Please join the project, if you are interested. We need more hands!

He describes some of the features already in the library - counterparts for parts of the current GObject world in PHP including GType, GSignal and GParamSpec. This is all on the master branch. In his "introspection" branch he's working on the introspection idea the GNOME community has been working towards too.

0 comments voice your opinion now!
phpgtk gobject binding github master introspection


Springboard Software Blog:
Using Introspection in PHP
June 27, 2006 @ 11:48:01

In this new post on the Springboard Software blog today, Michael takes a look at a very handy feature that PHP has to offer those working with objects - a form of introspection.

One of the things we love about Java is its ability to use introspection. Don't know what methods or field an object has? Just ask it.

It turns out that PHP provides some nifty introspection features as well. We've found one to be particularly useful: the ability of a PHP object to tell us its member variables at runtime. Not sure what that means? Let's look at an example.

In his example, he uses a content management system, specifically the "business objects" to illustrate his point. Introspection comes into play when the get_class_vars function is called, returning the defined variables for an object and allowing one to feed in values to be automagically set (in this case, either an array, a request, or a primary key for a record from the database).

0 comments voice your opinion now!
introspection objects businessobject get_class_vars get_class introspection objects businessobject get_class_vars get_class



Community Events











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


support application database hack facebook framework podcast performance symfony2 opinion release language hhvm composer introduction unittest component security package install

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