Actions

Difference between revisions of "Platform Applications Tips and Tricks"

From Joomla! Documentation

(Created page with "You can make web and command line applications on the Joomla Platform. The ==CLI Applications== To make sure you can run php on your command line you can do the following test...")
 
m (category added)
 
(3 intermediate revisions by 2 users not shown)
Line 3: Line 3:
 
==CLI Applications==
 
==CLI Applications==
  
 +
===Making sure you can run PHP CLI applications===
 
To make sure you can run php on your command line you can do the following test:
 
To make sure you can run php on your command line you can do the following test:
 
Make a file called clitest.php that consists of:
 
Make a file called clitest.php that consists of:
 +
<source>
 
<?php echo "Hello World"; ?>
 
<?php echo "Hello World"; ?>
 +
</source>
 +
 
Then at your command prompt type:
 
Then at your command prompt type:
 
php clitest.php
 
php clitest.php
Line 37: Line 41:
 
ini_set('error_reporting', E_ALL | E_STRICT);  
 
ini_set('error_reporting', E_ALL | E_STRICT);  
 
</source>
 
</source>
 
===Configuration===
 
  
 
===Configuration===
 
===Configuration===
Line 51: Line 53:
 
}
 
}
 
</source>
 
</source>
 
  
 
==Web Applications==
 
==Web Applications==
Line 77: Line 78:
 
}
 
}
 
</source>
 
</source>
 +
 +
 +
[[Category:Platform]]
 +
[[Category:Development Tips and Tricks]]

Latest revision as of 12:16, 29 August 2012

You can make web and command line applications on the Joomla Platform. The

Contents

CLI Applications

Making sure you can run PHP CLI applications

To make sure you can run php on your command line you can do the following test: Make a file called clitest.php that consists of:

<?php echo "Hello World"; ?>

Then at your command prompt type: php clitest.php You should get a Hello World message.


Setting Error Handling

 
// Set error handling levels
 
JError::setErrorHandling( E_ERROR, 'echo');
JError::setErrorHandling( E_WARNING, 'echo' );
JError::setErrorHandling( E_NOTICE, 'echo' );

Setting Error Reporting

Turn error reporting to high with:

/**
 
 * Turn on strict error reporting during development
 
 */
 
ini_set('display_errors', '1');
 
ini_set('error_reporting', E_ALL | E_STRICT);

Configuration

You can make a configuration.php file just like in the CMS to store your database and other information. Use fetchConfigurationData() to get the information.

If you don't need configuration you can do this:

        protected function fetchConfigurationData()
        {
        return array();
        }

Web Applications

Sessions with no database

If you are not using a database you should put:


// We're setting session to false because we aren't using a database so there is no where to store it.
$config = Array ('session'=>false);

to keep the application from attempting to store a session.

Configuration

You can make a configuration.php file just like in the CMS to store your database and other information. Use fetchConfigurationData() to get the information.

If you don't need configuration you can do this:

        protected function fetchConfigurationData()
        {
        return array();
        }