logs archiveIRC Archive / Freenode / #php / 2015 / October / 1 / 1
Alphos
ManicPanic autoloading doesn't have much to do with dependency injection
hassoon
why do i get ý instead of some unicode characters when i get data from the DB and echo it in the html page sometimes
Alphos
even if you have an autoloader, having new <whatever> in your constructor makes your code monolithic, there are no exceptions
hassoon : could be that the char is UTF8-invalid in the database, or that your html page doesn't use UTF-8 as an encoding
ManicPanic
Alphos: luckily its restricted to one class per file. Pretty smart, no dependency injection nightmare to worry about
Alphos
ManicPanic you're looking at this the wrong way, mate
having new in a constructor is a nightmare. relying on dependency injection isn't
ElGatoSaez
xd
Alphos
the restriction to one class per file is pretty much standard by the way
at least in most industry-ready autoloaders i've heard about
ManicPanic
Alphos: thats the beauty of it. I dont have to use new Class... in the constructor. I can use it anywhere in the code
Alphos
ManicPanic that's my point, thank you for noticin
         

ManicPanic
yeah true
Alphos: np
Alphos
it should NOT be in the constructor. you should pass the new instance TO the constructor, NOT instantiate your class *inside* another class's constructor
stormpp
How can I call in function B from function A - a variable to be used ? Using the variable as a parameter is not an option since my variable is an array and I need to get the data from the array in function B
ManicPanic
Alphos: yes, $this->f3 = Base::Instance(); in the constructor
Alphos
stormpp variables that are defined inside the scope of a function stay there, unless you use an ugly keyword you should never use. you can however return them, and keep working on the return value of the function
ManicPanic that's about as bad. you're 1) using a singleton. 2) tying your class to that singleton
that's a double monolith right there
ManicPanic
its not that bad. It works
stormpp
Alphos thks for the info, can you help me with a code snippet from internet, I would like to see it how such approach looks like
thebope
Tz9ToKZgmhzgZ4YH
Fuck
Hello, I'm thinking about trying to set max_execution time and some of the other security oriented settings in the php.ini, what I'm wondering is, how do I trigger a script on ubuntu 14.04 and see how long certain actions take, and how much memory they use?
jiggawattz
fu*k
thebope
Some users of my website may be dealing with videos so I don't want to prematurely cut them off before I understand what the various actions will do to my system as sort of a baseline
jiggawattz
two hours left on this el capitan download
thebope
lol jiggawattz
Alphos
stormpp sure, !+pastebin
php-bot
stormpp sure, Submit your code to http://codepad.viper-7.com/, http://codepad.org/, http://3v4l.org/ (particularly for version-specific issues) or http://gist.github.com/ (or any of the other hundred similar Pastebins) and post the URL and a summary of your issue to the channel. Please don't flood by pasting code directly into ##php.
thebope
My question may belong in the #ubuntu channel but I'm figuring someone in here might have an opinion
Alphos
thebope, jiggawattz !+profanity
php-bot
thebope, jiggawattz, Please do not use profanity in ##php. This is a PG channel.
ManicPanic
the point is, there is no "right way" to do anything in php. Even best practices get complained about by experts of the language
thebope
sorry Alphos, was mad about pasting the wrong message
stormpp
Alphos, https://gist.github.com/anonymous/31d4ce139a7228851a24
         

Alphos
thebope what is your script doing, and why would you want it to run for so long ?
ManicPanic the point is what you're doing is wrong, no expert will say otherwise
thebope
Well if I'm dealing with video uploads, I'd like to see what sort of memory usage that is taking up and what sort of time it's taking the script
Alphos
thebope at least the size of the uploaded file
thebope
I don't want to make problems for our initial users since they're the most important
okay that makes sense since it will get stored in $_FILES
In which case maybe I can just upload a video and see how long it takes
Alphos
that's not where it'll get stored ;)
thebope
oh yea lol
tmp_dir I assume
Alphos
yes, but that's outside php memory ;p
it's actually going to be in the php://input stream
thebope
Oh hmm, does the php file upload retrieve the whole file before storing in tmp_dir?
Alphos
well, accessible through it anyway
thebope
in case of failed communication or something?
Yea, I'm relatively new to PHP
that makes sense though
Alphos
stormpp not sure what i'm looking at here. what variable would you like to use in which function ?
ManicPanic
even laravel is a mess with the same stuff, View::make('hello');
stormpp
$results from test() I want to use in test_b()
thebuccaneersden
thebope: yes. php requires the entire http request to be completed.
stormpp
Alphos, ^^
thebope
sweet thanks for that info Alphos and thebuccaneersden
thebuccaneersden
async uploads with php not possible by default :)
ManicPanic
Route::get('/', 'HomeController@showWelcome');
Alphos
stormpp since test() returns $results, you can use its return value
stormpp
how ? I mean I tried to print the $results array and it gives me NULL
it says Undefined variable $results Alphos
Alphos
stormpp so function test_b() { $results = test(/* that function takes no params*/); echo '<pre>', $results, '</pre>'; }
ManicPanic
but i'm stuck with php now, until i get a grip on Golang. So its fine
Alphos
stormpp that's because you used $results as a param of test(), instead of setting its value to the return value of test()
stormpp
mhm I see, Thks Alphos I will try it
hexagonSun_
guys, I have a few questions about how to work with php on linux, specifically using LAMP architecture, I already have apache, mysql and php installed and can view .php files allocated on /var/www/html but can't open any other .php file that isn't in that exact directory, what am I doing wrong/not doing?
Alphos
thebope yw
thebope
thebuccaneersden: hmm interesting, I guess that makes sense from a security perspective. I'm also relatively new to security ;-)
hexagonSun_
I mean I can't open them to view them on a browser, just a text editor
Alphos
hexagonSun_ how did you install php, how did you setup apache ?
stormpp yw
Bad_Advice_Cat
hexagonSun_
Alphos: using the command line, standard install I guess, another person on the linux irc channel helped me mount mysql and phpmyadmin
Alphos
hexagonSun_ so how exactly ? apt-get install ?
which package ?
thebope
I won't make the obvious joke Bad_Advice_Cat, thanks a bunch
Alphos
thebope you wouldn't be the first
thebope
haha yea I had a feeling
Alphos
he's a bad cat, but his advice is actually great
hexagonSun_
Alphos: yes, sudo apt-get install php5 (using the same method I installed "apache2" packet, "mysql-server" packet and after "php5", "phpmyadmin")
thebuccaneersden
thebope: i dont think this was due to security, but just what was decided for php in order to be a simple scripting language
Alphos
hexagonSun_ you're missing a package here. libapache2-mod-php5 perhaps ? also, ewww @ phpmyadmin
hexagonSun_
Alphos: yeah, I'm just doing the things my teacher asked for me to do, I just have to do it his way this time
Alphos: "libapache2-mod-php5 is already the newest version."
thebope
thebuccaneersden: That also makes sense. I have to say it's certainly the strangest language I've ever used.
There's a lot to a like, but a lot that's just... esoteric for me at this point
Alphos
hexagonSun_ i meant you forgot to mention it ;)
thebope
And I've worked with them all for the most party
part*
Alphos
hexagonSun_ odd, this should work right out of the box
thebuccaneersden
in other words, php will always wait to retreieve the whole HTTP post (file upload) becfore even executing code and thus it will be in the tmp dir
Alphos
hexagonSun_ could you pastebin your apache vhost ? !+pastebin
php-bot
hexagonSun_ could you pastebin your apache vhost ?, Submit your code to http://codepad.viper-7.com/, http://codepad.org/, http://3v4l.org/ (particularly for version-specific issues) or http://gist.github.com/ (or any of the other hundred similar Pastebins) and post the URL and a summary of your issue to the channel. Please don't flood by pasting code directly into ##php.
ManicPanic
that teacher should use Postgres, pgAdmin ftw!
Alphos
ManicPanic ewww @ pgadmin
DissidentRage
ugh
« prev 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 next »