An ongoing list of notes that I've found useful over time, gathered in one spot.
Last active
December 28, 2017 21:11
-
-
Save tiffany-taylor/04c61ff033185a40f21f49e04602c6b8 to your computer and use it in GitHub Desktop.
Notes from projects
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Question: How does a function defined in a class access a property defined within the class? | |
e.g. | |
private $pageReader; | |
public function __construct(PageReader $pageReader) { | |
-- is just an argument for the method, whatever comes in creates the instance, e.g. | |
new Page ('this thing'); | |
$this->pageReader = $pageReader; | |
} | |
public function show($params) { | |
$data['content'] = $this->pageReader ... | |
} | |
-- just uses the property of the instance | |
Question: How would a class know to use which implementation if an interface and class exist? | |
How the decision is made is up to the developer, preferably using dependency injection. | |
e.g. | |
$page = new Page (new FilePageReader('/path/to/file')); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Error message: | |
Cannot create cache directory /home/tylae/.composer/cache/repo/https---packagist.org/, or directory is not writable. Proceeding without cache | |
Cannot create cache directory /home/tylae/.composer/cache/files/, or directory is not writable. Proceeding without cache | |
Problem is that ownership of the folder is not set to the user, so ownership needs to be switched. | |
I could not do sudo -R tylae /home/tylae/.composer/cache/repo/https---packagist.org/ because it does not exist yet, | |
so I needed to change ownership of /.composer. | |
sudo chown -R username /home/username/.composer | |
Running composer update would then work without error. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
I could not install composer from the script on the website (https://getcomposer.org/download/). composer -version would return an error. | |
running sudo apt install composer installed it. I'm not sure if it's the most updated version however. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
samayo | |
So I say put your config files and mysql databased on your shared folder | |
Tiffany | |
@samayo like nginx files? | |
samayo | |
Yeah | |
samayo | |
But for now take a snapshot | |
Tiffany | |
@samayo store them in shared folder, then symlink where necessary? | |
samayo | |
Symlink to the shared folder. I tried it once it's a bit of a hastle in the begining. | |
Tiffany | |
yeah, I can see the usefulness of doing it, but not looking forward to setting it up :P | |
samayo | |
Yeah it's a real pita .. but once I lost a year's worth of work b/c vbox crushed and I could not recover the mysql data | |
So you should probably start saving ..it weekly | |
Tiffany | |
snapshot or shared folder? | |
samayo | |
Your mysql data | |
Sometimes if there is no way to even start vbox a snapshot wont do you any good |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if some class has session_start how will you unit test it? i am getting cannot send session cookie --headers already sent. | |
https://chat.stackoverflow.com/transcript/message/38502494#38502494 | |
wrap it in a method and mock it when testing | |
class WhatYouAreTesting{ | |
protected function session_start(){ session_start(); } | |
} | |
$obj = new class(...) extends WhatYouAreTesting{ | |
protected function session_start(){ override; } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment