It is a bit mean to put such a headline on top, but thats the current status we have to deal with at our company. I also don't want to bash somebody, Log4Php is doing its job in a great way. But since i developed a proxy logger component, i want to use it. The proxy logger component can work with psr logger interface, so i need to create a adapter to get it used ;-).
The usage is simple, depending on the way you either choose the adapter "Log4PhpToPsrLoggerAdapter" or "PsrToLog4PhpAdapter". The only drawback, you are loosing the "trace" log level of log4php and all the fancy stuff of a log4php logger. This component is simple and has just a few lines of code (you are welcome to join), so the main focus is to support the log level methods like "$logger->warn()" and not more.
By using this component, you are able to use type hints also for basic data types.
This component includes class definitions for php basic data types like:
Boolean
Floating point
Integer
String
Numeric
Features
Enables type hints for basic php types
Types shipped with useful methods
Are comparable with native php types by using "=="
Provides generic type casting by implemented "toString()" methods (and so on)
Usage
Example
/**
* Class with type hint for string
*
* @author stev leibelt
* @since 2013-08-04
*/
class MyClass
{
/**
* @var array
* @author stev leibelt
* @since 2013-08-04
*/
private $strings = array();
/**
* Super cool method with type hint for string
*
* @author stev leibelt
* @since 2013-08-04
*/
public function addString(\Net\Bazzline\Component\DataType\String $string)
{
$this->strings[] = $string;
return $this;
}
}
$myString = new \Net\Bazzline\Component\DataType\String('super cool test string');
$myClass = new MyClass();
$myClass->addString($myString);
Hints
Extend provided types with classes in own namespace.
If you add a super cool method to your type, push it and be a part of the development team
I started developing this component because of the many casts i have to do while dealing with php's basic data types.
As general, i searched the web for existing and easy to use components but could not find them. If you find one, please tell me.
Last but not least SplTypes are still experimental.
So i had to evaluate a migration of an existing application from mysql 5.1 to mysql 5.5. Yes i know, the gap between 5.1 and 5.5 is tremendous but the system was working without any problems for a long time of periode.
After switching a test environment from 5.1 to 5.5 there was one unittest failing. What was so special in that given unittest? For a reason, we needed to execute the native propel method "reload" right after a "save". The test was failing because of an empty value for the "id". The representing database table has a column id with an autoincrement flag. With mysql 5.1, everything is working as expected. The id was available after the reload so everything was fine.
After switching to 5.5, no id was available after calling "save". This leads to the fact that propel was failing by executing the "reload" method. Switching back to mysql 5.1 and the error was gone. After search in usergroups, issuepages i still could not find any matching issue or entry. Finally i presentend my problem on the #propel channel in freenode and got some feedback. One guy had experienced the same error in the past. He could remember that this problem occures while switching to mysql 5.3 or 5.4. Niceguy exptom wrote that goosed him with my report and he will give the problem a debug session try.
On the next day, he quickly responded and presented his results. He (if he is a he and not a she) told me he could takle it down to a missleading schema.xml. The column where the error occures had a missing autoIncrement="true" value. I took a look into my current schema.xml and bam same flaw.
The rest is quite easy. Update schema.xml, rerun propel generation and testing. Everything is now working fine. Thanks to exptom again. I guess the schema.xml would have been one of the last areas i had debugged.
Pretty much, the code is below. It is a part of my function collection for the bash.
####
# Replaces a string in all files in given path and below
# taken from: http://www.cyberciti.biz/faq/unix-linux-replace-string-words-in-many-files/
# taken from: http://stackoverflow.com/questions/4437901/find-and-replace-string-in-a-file
# taken from: http://stackoverflow.com/questions/7450324/how-do-i-replace-a-string-with-another-string-in-all-files-below-my-current-dir
#
# @author stev leibelt
# @since 2013-7-30
####
function net_bazzline_replace_string_in_files ()
{
if [[ $# -lt 3 ]]; then
echo 'invalid number of arguments provided'
echo 'command search replace fileextension [path]'
return 1
fi
if [[ $# -eq 4 ]]; then
find "$4" -name "*.$3" -type f -exec sed -i 's/'"$1"'/'"$2"'/g' {} \;
else
find . -name "*.$3" -type f -exec sed -i 's/'"$1"'/'"$2"'/g' {} \;
fi
}