I deleted an entity and update the associations of my other entities. Then I regenerated my entities, and my schema. Doctrine still was querying for the old table though, the problem was APC was caching the query. Clearing the cache was annoying though.
First I tried clearing it via the command line
doctrine orm:clear-cache:query
But I got the error
Cannot clear APC Cache from Console,
its shared in the Webserver memory and not accessible from the CLI.
I found a bug for this though it doesn’t look like its been solved other then throwing an exception. To clear the APC cache you have to do it through the webserver.
So I created a php script
$cacheDriver = new \Doctrine\Common\Cache\ApcCache();
$cacheDriver->deleteAll();
And ran it through the webserver. This cleared the cache and fixed my problem. If someone finds a better way to do this please let me know.
Jack Doctrine
You can use the following command to create a backup of everything on on your linux box.
tar cvpzf backup.tgz –exclude=/proc –exclude=/lost+found –exclude=/backup.tgz –exclude=/mnt –exclude=/sys /
Jack Uncategorized
Zend Rest Client uses Zend Http Client, which has a low timeout of 10 seconds. Once again documentation for doing this was no where to be found so I dug into the libraries and found a way to change it. Basically you can return the reference to Zend Http Client and modify the config for its timeout. Because you return the reference you don’t have to worry about setting it again with setHttpClient().
1
2
3
4
5
6
7
8
9
| $client = new Zend_Rest_Client("http://arestwebservice/");
// Get instance of Zend_Http_Client
$httpClient = $client->getHttpClient();
// Change the timeout
$httpClient->setConfig(array(
"timeout" => 180
)); |
Thats it! Your timeout is now 3 minutes.
Jack Uncategorized
I set up a Zend Rest Server which went really well. Then came time to use the client. I went through the documentation I found here
http://framework.zend.com/manual/en/zend.rest.client.html
As usual with Zend, the documentation didn’t describe the basic functionality that I needed. So I read through the source code and figured out how to use it. Here is a basic example of usage for a rest server that manipulates users.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
| // instantiate rest client
$client = new Zend_Rest_Client("http://myrestserver/");
// Run GET operation for user with ID of 1
$response = $client->restGet("/user/1");
// Print response
print $response->getBody();
// Add new user
$userInfo = array(
"username" => "someuser",
"password" => "password"
);
// POST user information to rest web service
$response = $client->restPost("/user/",$userInfo);
// print out response
print $response->getBody(); |
This is just a basic example, I haven’t used PUT or DELETE yet but I assume they work similar to GET and POST.
Jack Uncategorized
Here is a quick function I threw together, it checks for federal US holidays and returns either the holiday name or false.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
| function checkHoliday($timestamp)
{
// get date
$date = date("M-d",$timestamp);
// get year
$year = date("Y",$timestamp);
// MLK
$mlk = date("M-d",strtotime("{$year}-01-00 third monday"));
// Washingtons birthday
$washington = date("M-d",strtotime("{$year}-02-00 third monday"));
// Memorial Day
$memorial = date("M-d",strtotime("{$year}-06-01 last monday"));
// Labor Day
$laborDay = date("M-d",strtotime("{$year}-09-00 next monday"));
// Columbus Day
$columbusDay = date("M-d",strtotime("{$year}-10-00 second monday"));
// Thanksgiving
$thanksgivingDay = date("M-d",strtotime("{$year}-11-00 fourth monday"));
// build array of holidays
$holidayArray = array(
"Jan-01" => "New Years",
"Jul-04" => "Independence Day",
"Nov-11" => "Veterans Day",
"Dec-25" => "Christmas",
$mlk => "Martain Luther King Day",
$washington => "George Washington's Birthday",
$memorial => "Memorial Day",
$laborDay => "Labor Day",
$columbusDay => "Columbus Day",
$thanksgivingDay => "Thanksgiving Day"
);
if(isset($holidayArray[$date]))
{
return $holidayArray[$date];
}
return false;
} |
Jack Uncategorized
I repeatedly have had my sound driver crash. It usually happens every couple days or so. I use the following to restart the sound driver, and get the sound going again.
rcalsasound restart
Jack Uncategorized
To change your IP address from the command line first determine which device you want to set it for, type
If you have an ethernet card you should have a device called something like eth0, if you have 2 then you will probably have eth0 and eth1 if you have a wireless card you might have something like wlan0. You want to select the device you want to change your ip address for, for me it was eth0, and I did it like this
first i set my ip address
ifconfig eth0 192.168.1.55 netmask 255.255.255.0
then i set my gateway
route add default gw 192.168.1.1
If you just want a new ipaddress from a dhcp server you can just do
All of these commands must be done as root
-Jack
Jack Linux
Ok so you are tired of entering your password each time you ssh to a server, here is how to set up keys so you can automatically log in. You can also use this to run automated tasks on your servers without having to be there to type in the password or storing the password in a script file.
First you want to create your keys you can do this like with ssh-keygen, do not enter a pass phrase
Now you should have the file ~/.ssh/id_rsa.pub
On the box you want to log into there might be a file called
~/.ssh/authorized_keys2
If it isn’t there you can create it and edit it manually or you can use the following steps either way
cd ~/.ssh
scp id_rsa.pub {your username}@{remoteserver}:~
ssh {your username}@{remoteserver}
cat id_rsa.pub >> .ssh/authorized_keys2
Now you should be able to login to the server without having to use your password
-Jack
Note: The authorized_keys2 file needs to have permissions set to 600 or it will fail. It wont allow loose permissions.
Jack Linux
I generally like to map my Caps Lock to my Escape key mainly for when I’m using vim, on the keyboard layout available when vi was originally created, the escape key was where the tab key is now. The current location of the escape key requires me to move my hands out of their “typing position”. So mapping the Caps Lock key to the escape key is pretty useful for me. To do this all i had to do was add the following to .xmodmap in my user directory.
clear Lock
keycode 0x42 = Escape
This will run at startup, to run it after you make the change do
Jack Linux