- Noobs - A way to try all the main ones in one re-imagiable download.
- Raspbian “wheezy” - Recommended, with development tools.
- Soft-float Debian “wheezy” - Same as Raspbian but compiled for the slower soft-float hardware. Used for Oracle JVM version 7 or less.
- Arch Linux ARM - Boots in 10 seconds but definitely not for beginners.
- Pidora - Fedora.
- RISC OS - Acorn.
-
Introduction: Concepts, MVC architecture and Active Records. Part 1
-
Setting up your development environment. Part 2.1 Part 2.2 Part 2.3
-
Creating your first Yii application. Generate Controllers, Views and Models via Gii. Connect to database. Friendly URLs. Part 3.1 Part 3.2 Part 3.3 Part 3.4
-
Yii Architectural Review. Yii is scalable, supports CRUD actions, MVC but is not classed as an enterprise application framework because it doesn’t support transactions, no business rules or constraints, no workflow control. Part 4
<?php
include("header.php");
?>
The page and maybe some more PHP.
<?php
include("footer.php");
?>
If “The page and maybe some more PHP.” is the view then the rest is the layout. Or to put it another way a layout is a decorator for a view.
A nice example of this is the Blog demo. The view contains all the page specific body but the menus and side bars are held in the layout. You could add the layout to each view and not use layouts at all but this would mean repeating a lot of the same code across all the views.
The first thing to understand is the precedence of the layout overrides. As with all these things the closer to the code that’s running the higher the priority.
- Action: With the highest priority, this layout can be set inside the body of the controller action.
class SiteController extends CController { public function actionIndex() { $this->layout = "mylayout"; $this->render('index'); }
- Controller:The layout can be set at the controller level by overriding the layout variable from the base class.
class PostController extends Controller { public $layout='column2';
- Theme: The layout may be taken from the current theme.
- Module: The layout may be taken from the current module.
- Parent Modules: If the current module has no layout, then traverse up its parents until you find one.
- Default: Finally the Yii application defines the default layout [
Yii::app()->layout
] which is meant as a catch all. - None: All these places are searched but if at the end of the day they don’t point to anything then a layout won’t be used.
/helloworld/
is accessed and Yii looks for the configuration file/helloworld/protected/config/main.php
in order to find the first controller to load.- The
main.php
configuration file is not found so Yii then looks for the default controller called Site. It loads/helloworld/protected/controllers/SiteController.php
- The default action for a controller is Index so
actionIndex()
is called which just echos some stuff to the screen.
/hangman/
is accessed and Yii looks for the configuration file/hangman/protected/config/main.php
in order to find the first controller to load.- The defaultController is game, so Yii loads
/hangman/protected/controllers/GameController.php
- The default action has been set to “play” by overriding the
defaultAction
field of theGameController
class. SoactionPlay()
is called first. - At the end of
actionPlay()
the functionrender()
is called with either “guess” as the view or “play". Let’s continue assuming “play” was selected. - Now Yii will render
/protected/views/game/play.php
into a variable. - Next it will look for a layout to place that rendering. Following the priorities from above it will eventually get to the default layout for the application (CWebApplication) which is
layouts/main.php
- Yii will make sure that
layouts/main.php
exists then it will render that layout, setting $content to the result of rendering the view file.
main.php
is the default catch-all layout and column1.php
& column2.php
are intermediate layout files.
/blog/
is accessed and Yii looks for the configuration file/blog/protected/config/main.php
in order to find the first controller to load.- The defaultController is post, so Yii loads
/blog/protected/controllers/PostController.php
PostController.php
sets the class layout to “column2″, so all views will use “column2″ as their layout.- The default action is Index so
actionIndex()
is called next. When it gets to the end it callsrender()
to render the index view. /blog/protected/views/post/index.php
is used to draw the blog posts and the result is returned to the renderer.- The renderer uses the result of the view-render as the $content in the column2 layout.
- The column2 layout has the following form. It means that stuff between
beginContent
andendContent
will be given to/layouts/main
as its $content.<?php $this->beginContent('/layouts/main'); ?> ...stuff... <?php $this->endContent(); ?>
I would like to debug PHP in Eclipse PDT while it runs under an Apache server with a bit of MySQL thrown in. In order to do the remote debug one needs to configure PHP to use XDebug which is a standard cross-platform debugger that is used by a variety of languages to debug over the wire. It is based on DBGp, a common debugger protocol for languages and debugger UI communication.
I downloaded and installed XAMPP which bundles together a LAMP stack in one easy download and installs them so they all work together (or so I thought).
I followed the standard instructions to switch on XDebug except that I installed it under e:\xampp
instead of the default c:\xampp
.
- Launch the XAMPP Control Panel.
- On the Apache row click Config, then PHP (php.ini) to load the PHP configuration file.
- Forward search for [XDebug]
- Make sure the following options are uncommented (i.e. remove the semi-colon at the front of the line) and fill in the entries to match those below.
[XDebug] zend_extension = "E:\xampp\php\ext\php_xdebug.dll" xdebug.remote_enable = 1 xdebug.remote_handler = "dbgp" xdebug.remote_host = "127.0.0.1" xdebug.remote_port = "9000"
- Stop Apache
- Start Apache
On starting Apache the following message pops up:
The procedure entry point zend_unmangled_property_name_ex could not be located in the dynamic link library php5ts.dll
After a lot of really boring reading in the usual forums and help web sites I find out that the php_xdebug.dll
is not compiled correctly for the version of PHP I'm using. This is very strange because it was downloaded as a bundle so everything should be compatible with everything else, but it wasn't.
To confirm this type:
cd e:\xampp\php
php -m
which gives the following output:
Failed loading E:\xampp\php\ext\php_xdebug.dll
[PHP Modules]
bcmath
bz2
calendar
Core
....
zip
zlib
[Zend Modules]
Microsoft Windows dictates an internal DLL binary format which coincidentally is released with a new version of Microsoft's Visual studio. This makes programs compiled with different versions of compiler incompatible with each other - thanks for that. It causes problems in every computer language that is compiled with a Microsoft compiler. PHP is just one of them. Python is another. If you compile Python under Visual Studio 9 you will have to recompile all the support modules with the same compiler. So not only do you have to care about whether it was compiled into 32 or 64 bit code but you also have to care about which compiler was used too.
The name of the XAMPP binary tells you which version of Visual 'C' was used to create the application suite. In my case I downloaded xampp-win32-1.8.2-0-VC9-installer.exe
paying special note to the win32 and *VC9** in the file name. From the file name we can see that this is a windows 32 bit version compiled using Visual 'C' 9.
This only gives us some of the story. For the rest we need to run XAMPP and get it to tell us how it was compiled. In the document root E:\xampp\htdocs
create a file called p.php
and fill it with:
<?php phpinfo(); ?>
Next open you browser and go to: http://127.0.0.1/p.php.
There are several lines of importance:
PHP Version 5.4.16
Compiler MSVC9 (Visual C++ 2008)
Architecture x86
Zend Extension Build API220100525,TS,VC9
PHP Extension Build API20100525,TS,VC9
The phpinfo()
confirms that Microsoft's Visual 'C' version 9 (MSVC9) was used as the compiler which was built in Visual C++ 2008. The Visual C++ 2008 tells us that the Apache needs the Visual C++ Redistribution libraries to be installed. You wouldn't be able to run Apache with out them. If may explain why XAMPP may work on a newer server but give DLL errors on an older one.
x86 is the hardware architecture and indicates that it is a 32 bit build.
Zend Extension Build and PHP Extension Build have their compiler options although in this case the only important part of this is the TS bit. I think that in some builds of PHP the TS may not exist or it might be NTS instead.
Next we have to download a new version of XDebug that will fit into our environment. So navigate to: http://xdebug.org/download.php
In the Releases section look for the version that has the compiler flags we need. We'll start with the latest version (XDebug 2.2.3 at the time of writing). I'm using PHP version 5.4 compiled using VC9 with TS and for a 32 bit build. So I download PHP 5.4 VC9 TS (32 bit) (php_xdebug-2.2.3-5.4-vc9.dll).
There are 2 ways to install it.
- Rename
php_xdebug-2.2.3-5.4-vc9.dll
tophp_xdebug.dll
- Stop Apache
- Copy
php_xdebug.dll
intoE:\xampp\php\ext
- Start Apache
Windows being what it is with locking files means that you have to stop Apache before copying the DLL in to the correct place which will slightly increase the downtime. This might work better as a tested upgrade on a production system where you don't want to touch the configuration files.
Alternatively you can:
- Copy
php_xdebug-2.2.3-5.4-vc9.dll
into theE:\xampp\php\ext
directory - Edit the zend_extension line in the
php.ini
to point to this version.[XDebug] zend_extension = "E:\xampp\php\ext\php_xdebug-2.2.3-5.4-vc9.dll" xdebug.remote_enable = 1 ....
- Stop Apache
- Start Apache
Most people choose this option because it gives you a better infrastructure for testing different versions as well as an easy rollback or upgrade path in case anything goes wrong. It also reminds you which version of XDebug you are using. The DLLs stay in place and you are only changing the configuration files. As a result there is no gap between the Apache restart.
Finally navigate to your phpinfo()
page and there should be a section for XDebug.
- The problem happens more often than not on SDHC type cards.
- Mac has some out-of-specification code to write to SD cards which is not compatible with other card readers.
- There is a fault with the onboard card reading which falsely reports that the physical read-only lock is active.
- It matters how you insert the SD card into the SD reader’s slot.
- All problems can be solved by using an external card reader.
/dev/disk1
so I’ll use that in the work-around procedure that follows:
- Open a terminal window and type:
$ ls -l /dev/disk1* br–r—– 1 mrn operator 14, 0 11 Jun 00:24 /dev/disk1
- Make sure the SD card’s physical switch is pressed down in the unlocked position. There should be a label on the card itself to remind you.
- Insert the card firmly applying the pressure directly along the line of insertion.
- Run the above line again to check the read-only status.
- If the device still reports as read-only, pull the card out and insert your fingernail in between the physical lock switch. The gap should remain when you remove your nail, then repeat the test.
- Increase the width by about a fingernail’s worth each time you run the test and eventually you will reach the sweet spot. The test will report:
$ ls -l /dev/disk1* brw-rw—- 1 mrn operator 14, 0 11 Jun 00:24 /dev/disk1