Showing posts with label cakephp tuts. Show all posts
Showing posts with label cakephp tuts. Show all posts

[Docker] Composer with Intl Extension

Well, I recently convert my apps to docker. And I feel like, it's awesome! I can reinstall my Ubuntu for 1000x hahaha.. By dockerizing my apps, I'm no longer confused on setting the apps every time. It's like I can run it everywhere with the same configuration.

One of the dockerized apps I've used is, composer. Of course it's a main apps. How can I work if I cant use composer. Back in the past, I installed composer in a container. Later, I knew it was not a good practice. Working with docker, means we are working with root mode. And we shouldn't run composer in root, right? Beside, it's not best practise to install docker in a container. It's quite finicky to run inside a container and run composer. It's a nope then.

Official docker composer

There's an official docker composer out there. You can find it here: Docker Composer. The instructions are clear. I'm sure you could follow it. Once I used it, but I'm using another now hahaha.. This official docker composer doesn't come with intl-extension which I really need in order to get the framework done. I'm using CakePHP 3 which it's rely on Symfony library. And Symfony needs this intl extension. For normal uasage, this composer would suits most people.

Docker composer with intl [see update]

This is what I need. In short, go to this docker hub. What a life saver. Now I could work again #yay. Do you know how I'm suffering by using composer inside a container? It's a lot, dude! Grab it and spend your hours on something else!

PS. You still need do the instructions in official docker composer in order to make it works. Just adjusted the image to docker-with-intl composer, since the hub is quite simple :D

Update 31 August, 2016

How to add extension php-intl
I got another answer. This one is from the author of docker-composer, RobLoach. He said, if we could just pass `--ignore-platform-reqs` when running the composer. Well, and it just works. For detail option, please refer to composer docs (https://getcomposer.org/doc/03-cli.md) as well. 

Important quotes for all typists all over the world


Today, I'm looking for some references about UNION on MYSQL, and one of tab I opened is from stackoverflow.
Here is a quotes I copy from the site :
Too many coders [thom : I read it as typists] try to limit themselves to the functionality of a framework. DONT. use what the framework provides. If it does not have the functionality you seek, then either:
  • Code the functionality you need into a class extension
or
  • Custom spin the code within the framework to suit your needs.
Often, developers try to hammer a square peg into a round hole and wind up doing way too much extra work that really only makes the code complicated. Take a step back and ask why you are using the framework to begin with. It brings structure to an unstructured language. It provide solid reusable foundation to build your application on. It is not intended to be a box to put yourself in and be limited.

I think there is something in it, so that I copy it into this blog. What do you think?

[Solved] updateAll cakePHP unable to fire callback

Still on logging sql-queries to database. This day, I was stuck on updateAll that was unable to fire callback afterSave(), not like normal update using save(). I thought my scripts was wrong -and yeah it was, even just a lil. And, damn, it still doesn't work! The other, delete and insert are normal. I mean, it's executed and written in log table like expected. In my case, the updateAll() is just executed and nothing happen in log table.

I still had positive-thinking about 'there was something wrong within my script' that I still don't know what is it. Had a thought what if updateAll() is not firing the afterSave callback, so I did a lil bit experiment. Just say it try-and-error. 

So, finally my thought about 'afterSave() is not fired by updateAll' was strengthen. I was so sure if indeed it was. And, I did googling and tadaaa.. By default, yes, updateAll() is not designed to fire callback because of security reason. 
This is by design. Since updateAll can take any SQL expression for updating conditions its not possible to know for which individual records to run the callbacks without adding lot of overhead like first doing finds and making list of ids of records that will be updated.

http://cakephp.lighthouseapp.com/projects/42648/tickets/2459
Clear enough. But like @mark_story told me :
Of course, its just PHP,,,


That means,, everything is possible :D What did I do? Let's go to the how-to section..

Accessing Session Variables in Model

This early morning (right now based on Indonesia time GMT+7, it's 8.18 AM), I've been preparing my to-do-list to be done later in my office associated with my countdown-project. It's all about to log every query executed by user action (create/ add, edit and delete) to database by using cakePHP. I've been spending a lot of time on searching the snippet or at least what-kind-of-function-I-must-used-to, and not find my need yet.

Yesterday, since I've found the how-to, based on the link I've found on Stackoverflow and edited it to be like what I want (read : need), I still have to do a lil bit experiment.

It's like this title's post. Accessing session variables in Model. Is that possible? Come on,, it's just PHP. Anything possible.


SVN : Attempt to Write A Read Only Database

First time I knew 'subversioning' was not long ago. It started when we have a server in our office, a few days before now. Might be a week? I think so. Back to topic. We build our own server using Ubuntu Server 11.10. And we try our subversion apps, we stucked at error when commiting. The error was 'attempt to write a read only database'..

But now, the prob is fixed :) Here our way to fix it

CakePHP 1.3.x : Change Favicon

I remember one thing. Yesterday, I'd like to change the cake's default favicon on my current project. Yeah, as we know, the default cake's favicon is a cake logo. There was a story. A long time a ago I successfully change it. Buuuut. I just forget the way. What the..

['How to' Section]
Anyway, I've re-found the way myselft. Just simply replace favicon inside app/webroot with your own *.ico favicon. And you're done :D

[Tips]
You could use online image converter (favicon generator) to convert your image to *.ico extension. Just do a short googling to find it. :P

Ummm... one thing. If your favicon won't show after you do this thing, Re-refresh your browser. Or, just simply clear web history.