Download the PHP package acplo/acplolog without Composer
On this page you can find all versions of the php package acplo/acplolog. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package acplolog
AcploLog
Introduction
This module provides some useful log classes:
- ErrorLogger = PHP error and Exception
- EntityLogger = Doctrine ORM Entity
- SqlLogger = Doctrine DBAL SQL
- StaticLogger = "Shortcut" to a generic file logger. Can be attached to the Z-Ray in Zend Server (NEW)
Requirements
This module only requires zendframework 2 framework.zend.com.
Instalation
Instalation can be done with composer ou manually
Installation with composer
For composer documentation, please refer to getcomposer.org.
- Enter your project directory
-
Create or edit your
composer.json
file with following contents: - Run
php composer.phar install
-
Open
my/project/directory/config/application.config.php
and addAcploLog
to yourmodules
Usually insert as the first module to enable catch errors and exceptions in all modules.
Installation without composer
- Clone this module AcploLog to your vendor directory
- Enable it in your config/application.config.php like the step 4 in the previous section.
Usage
To change the options, copy the file acplolog.global.php.dist to your config/autoload/ , rename it to acplolog.global.php and change the default options.
ErrorLogger
To enable the ErrorLogger just add the registerHandlers inside your public/index.php
You can use the logger with your phpunit tests. Just call it in your bootstrap file just after the autoload is created:
Output examples
PHP Error
Exception
The default logfile is data/log/error.log
EntityLogger
The first usage is to dump a Doctrine Entity to the screen, either HTML or console.
To do that just call a static function:
and it will print:
The "dump" function provides two more arguments:
The second argument indicates how depth will be the dump (other classes as properties, including collections) with default to 1 and the third if the output will be HTML friendly (encloses the output in a "pre" tag) or false for a console version with a default to true.
and it will print:
and it will print:
The second usage of this class is to save database operations generated by your entities.
ATTENTION: This logger depends on DoctrineORMModule. Since its usage is optional, i did not put this requirement inside the composer.json
To enable this logger, register inside your doctrine's config (e.g. config/autoload/global.php)
will generate:
The default logfile is data/log/entity.log
SqlLogger
With this logger you can save all Doctrine database operations within your application.
ATTENTION: This logger depends on DoctrineModule. Since its usage is optional, i did not put this requirement inside the composer.json
Edit the config/autoload/acplolog.global.php file to enable this logger.
The default logfile is data/log/sql.log
StaticLogger
This logger is usually used to log development or debug messages, arrays and objects. Just call it statically anywhere in your code.
will generate
Or an object:
will generate
Optionally, you can get it through Service Locator
The default logfile is data/log/static.log
Z-Ray
Z-Ray is an awesome resource from Zend Server that provides several information about the request, errors and the framework. It also has the possibility to add your own informations, so i added the StaticLogger messages to it.
More information can be seen here.
Warning: The Z-Ray extensions works only on Zend Server 8 or greater.
Installation
To use the StaticLogger with Z-Ray, follow these steps:
1- Locate the zray extension directory inside the zend server.
For example on Mac/Linux can be found on: /usr/local/zend/var/zray/extesions
2- Create a directory called AcploLog
3- Copy the zray.php and logo.png to this directory
The final result should be:
Usage
Just use the StatticLogger and the messages will appear inside a AcploLog section of the Z-Ray bar.
Optionally, you can pass a "null" value to the file argument to use just the Z-Ray, without writing the message to a file: