2009
11.22

JSON is a perfect way to use an object in backend and frontend.

Here, I’m gonna create a Symfony task to modify your table models for adding toJson method. toJson method returns a JSON object from your table model.

symfony generate:task propel:add-toJson-method

Run the command above. That will create a task file into lib/tasks/propelAddtoJsonmethodTask.class.php
Edit that file via your code or text editor and find the commented line including add your code here
There’s where we are going to put our codes.

First we need to find model directory. If there is a broken link or something to get us unable to reach model directory we throw an exception.

$models = array();

$dir = realpath(dirname(__FILE__) . ‘/../model/’);
if (!is_dir($dir))
{
throw new Exception(’Unable to find model directory’);
}

If we find model directory then we need to find all model classes. Actually, to find Peer classes is fine. We won’t touch any other files. At that point, we need to aware of that we can’t modify any file under sub directories. Because they’ll be re-created at next building process. If we can’t find any file that we needed we throw an exception.

$dh = opendir($dir);
while (($file = readdir($dh)) !== false)
{
if (substr($file, -4) == ‘.php’)
{
$model = explode(’.', $file);
if (substr($model[0], -4) == ‘Peer’)
{
array_push($models, $model[0]);
}
}
}
closedir($dh);

if (!count($models))
{
throw new Exception(’There is no class for any table in model directory’);
}

sort($models);

In next step, we need to parse those files and find a place to put our code.

foreach ($models as $m)
{
$tablePeer = new $m();

if (!method_exists($tablePeer, ‘toJson’))
{
$code = trim(file_get_contents($dir . ‘/’ . $m . ‘.php’));
if (substr($code, -2) == ‘?>’)
{
$code = trim(substr($code, 0, strlen($code) -2));
}

if (substr($code, -1) != ‘}’)
{
throw new Exception($m . ‘: unable to parse’);
}

$code = trim(substr($code, 0, strlen($code) -1));
$code .= “\n static public function toJson(” . ‘$obj’ . “) {\n ” . ‘return json_encode($obj->toArray());’ . “\n }\n”;
$code .= “}\n”;

file_put_contents($dir . ‘/’ . $m . ‘.php’, $code);
}
}

Now, we can call our task in command line:

symfony propel:add-toJson-method

Click here to see source code.

Also, you can use Propel Behaviors in Symfony to perform that. Documentation is online at http://www.symfony-project.org/cookbook/1_2/en/behaviors

Comments Off
2009
11.03

You can find what Solr is exactly at http://lucene.apache.org/solr/#intro if you don’t know already. I’m gonna tell you how to compile it yourself:

If you have given an error about PHP version you need to change version controller to your current PHP version in php_solr.c (For example, I changed it to 5.2.6) The developer asks for 5.2.11 version but I have no idea why. I asked him about that but no answer yet. If anything comes up I’ll update this post immediately.

First of all, download the source from here.

apt-get install libcurl4-openssl-dev
apt-get install libxml2-dev
phpize
./configure
make install

Comments Off
2009
10.28

Comments Off
2009
10.13

# Iyi derecede Html, Xhtml, JS, css ve web 2,0 bilgisine sahip
# Flash Tasarim(Adobe Flash) ve Tercihen Action Script konularina hakim
# Özgün Tasarim yetenegine sahip
# Windows platformunda Photoshop, illustrator, Flash gibi tasarim araçlarini çok iyi seviyede kullanabilen
# Güncel Web tasarim araçlarini iyi seviyede kullanabilen
# Yüksek algilama, hayal ve gösterim yetenegine sahip
# Motivasyonu yüksek, analitik dü?ünce yetenegi gelismis
# Ögrenmeye Açik
# Erkek Adaylar için Askerligini tamamlamis ve ya en az 2 yil tecili bulunan
# Temel ingilizce bilgisi
# En az 2 yil aktif is tecrübesi
# Tercihen Anadolu yakasinda ikamet eden

Guncel ozgecmislerinizi dogrudan bana iletebilirsiniz. (me-at-umut-dot-mobi)

Güncelleme: Pozisyon doldu.

Comments Off
2009
07.28

Main purpose of software projects is that making useful, user-friendly and qualified solutions for customers. According to market research companies, many of software projects can’t see the end of river. There are 5 important truths that I’m gonna say about that kind of projects.

* First analysis and report part takes long time more than necessary. Analysis or reporting team confuses by the details.
* Because of first approach, development team needs more time to work productive. That means there will be useless period of time.
* Many times, a request which is asking in during development part changes existed modules. Thus the project gets more risky. Realizing problems take long time.
* After all these situations, team gets away from first analysis of the project. They work overtime to catch the plan or they redesign the project. First way makes team exhausted day by day and the second way takes long time. Both are wasting time.
* While team deciding to budget, they don’t think about extras or requests. Thus project needs to more money eventually.

Comments Off