logs archiveIRC Archive / Freenode / #php / 2015 / September / 26 / 5
Sammitch
*the objects themselves
retran
whatever you wanna call it
Alphos
retran ok, so definitely not injection
__adrian
"Factories make things"
retran
they just "have" them available
Bad_Advice_Cat
Hmm, I can show a sample of what I do in my code base. xD
Alphos
retran : ok, so you're tying your dependencies, that's exactly what dependency injection aims to remove
retran
why isn't it. does injection mean it has to be fed to the dependant classes constructor?
Alphos
yes, injected as they are needed
         

KLVTZ
Good Morning All, could anyone help me out with the following problem. I contained the issue and question in a gist: https://gist.github.com/KLVTZ/657c86ba1db340055a48
retran
ok, so i have them being injected
the resolver is calling a contructor (or some other method it derives by looking for interface instance)
and sending the dependancy straight in
one sec... you could tlel me
Alphos
function foo($bar, $baz) { echo $bar*$baz; }// instead of function quok() { $bar = /*something*/; $baz = /* something */ ) { echo $bar*$baz; }
retran
https://github.com/katmore/flat/blob/master/app/api/hello.php
the GET_method and POST_method methods in there
i believe that fits the DI injection pattern
the dependency is the $input object (already created, mapped)
or am i missing something?
STEVOOO
is PHP fully OOP?
Alphos
retran seems about right
retran
cool.. i think i "got it" as far as what DI is now
Alphos
STEVOOO no, it's not. it can be procedural or functional (although good luck with that)
STEVOOO why would you ask ?
retran
not that i did any of that on purpose
hmm... to a purist is Smalltalk even fully OOP?
caffinated
to a purist smalltalk is the definition of fully OO
x0rs
Hey folks, I am using a pretty standard contact form written in PHP for a website I am designing, but it is very slow to process. Are there services that I can use to embed or integrate with that will improve the speed and professionalism of a standard contact form?
retran
perhaps there's purists so puritanical they disagree :D
Alphos
KLVTZ loop over the domnodelist of your elements, and loop over the $attributes DOMNamedNodeMap of each of your elements
retran
let's see ... what's the state of PHP's OOP weaknesses now with 7
KLVTZ
Alphos: thank you for you replying. Wanted to make sure I was on the right path
retran
on a scale of 1 to 10. 10 being Smalltalk, 1 being C.... how does PHP rate for Polymorphism, Inheritance, and Ecapsulation
caffinated
it supports all those things, I'm not sure what you're trying to get at.
retran
I'm wondering why someone would say "PHP isn't OOP"
that's what I'm getting at
caffinated
Because they don't know what they're talking about
OO features are just features. the ability to mix paradigms doesn't suddenly make a language "not OO"
it might make your software not strictly OO, but that's a different story.
I mean, think of it this way. If I write a largely OO program in Python, and I do one part in functional programming, does it suddenly mean python is not an OO language?
Alphos
the question was if it was "fully" OO. it isn't. it allows other paradigms
         

caffinated
Alphos: and what does that even mean?
retran
you are saying that "is X fully OO" is an exact synonym "can it do anything that isn't OO"?
(err.. antonym)
caffinated
if it's just "does it have all the features to be considered an OO language" the answer is yes.
Alphos
of course
if it's "will it stop working if you use another paradigm", the answer is no
rachelfish
Hi there ##php
Are there any tools for debugging / benchmarking PHP? For some reason on my local machine pages take a long time to load even though they work fine on production
I'm interested in finding some way of determining what functions are taking the longest to execute, or maybe even monitoring network / database requests too?
Is there any sort of PHP debugger I could install to see this kind of information?
retran
when i hear the question "Is such-and-such language fully OOP".. i thnk they're asking does it implement the core features of OO (inheritence, encapsulation, and polymorphism)
caffinated
rachelfish: http://xdebug.org http://php.net/xhprof http://php.net/debugger
retran
here's a question. why would anyone want to make a web application in prolog
rachelfish
caffinated: Thanks, but do you have any resources that show using these debuggers in the way I asked?
caffinated
rachelfish: did you bother to open any of those pages and look?
rachelfish
For example I looked at the xdebug documentation and mostly it's geared towards adding stack traces to error messages and things
Yes
retran
stack traces which display exec time
rachelfish
In my case, I want to measure all of the scripts' activity, regardless of if there is an error or not...
caffinated
http://xdebug.org/docs/profiler - two clicks in
and xhprof IS a profiler
rachelfish
Thanks caffinated
I've used xhprof before but it didn't have any way to monitor network activity
caffinated
it isn't a profiler's job to measure network activity.
a profiler is specifically for timing how long code takes to execute, and logging metrics about what gets called.
if you want to monitor network activite, you shouldn't be looking at debuggers for php
Bad_Advice_Cat
retran, something like this, when you set up dependencies (Typically done using a Dependency injection container) https://bpaste.net/show/3ed34a256adb
retran
i see this whole ->addRule() thing...
Bad_Advice_Cat
The point of this is to set up dependencies, WITHOUT instantiating your objects. - When you do actually instantiate, you are NOT using the "new" keyword, and you have an object created for you.
retran
but surely the point isn't simply avoiding a particular keyword?
caffinated
no, it's compositional
Bad_Advice_Cat
There are many dependency injection containers you can use. Pimple being the most popular DIC container: http://pimple.sensiolabs.org/
retran
meaining?? you can use the same dependant object over and over within the same script without having to instantiate it unnecessarily?
zach_
rachelfish: you don't have to monitor network, but you can see the walltime of a fsockopen() function or curl_exec() and obtain that information via a callgraph using xhprof
retran
or... is it to separate the logic between configuring the dependancy and USing the depdenecy?
Bad_Advice_Cat
retran, only reason I mentioned "pimple" is because it's something I think you've heard of before. - There are many other containers that does the job, some better than others (pros/cons, etc) - http://www.sitepoint.com/php-dependency-injection-container-performance-benchmarks/
Pimple imp is the easiest to understand.
imo*
https://github.com/container-interop/container-interop#projects-implementing-containerinterface <-- This is a better link that lists all the containers, forget the above one.
retran
the link you provided me, is that only hte injection container
and the class relying ona dependancy would just refer to a particular container?
wait... no because it's getting it in a constructor (or some other method)
ok... criticism time
Bad_Advice_Cat
WITHOUT instantiating your objects. <-- This is by the way known as Lazy loading. To load/create objects, only when necessary. retran, it's kinda what you did with Composer. Only loading classes, WHEN it is necessary.
retran
why have some assoc paramer named "constructParams" when the language already has a way to do constructor/argument
why not do it in the natural language, but say.. use a closure or something
__adrian
you can use a closure. works great.
Bad_Advice_Cat
retran, that is done "in the background", you dont actually see it.
retran
i assumed that
but why is there this "rule" thing that replicates language syntax
__adrian
that example takes a different approach; you give it _instructions_ and then it can follow them to create objects when needed.
Bad_Advice_Cat
retran, constructParam is used to say "inject things in here" , we do not use the NEW keyword, becauase we do not want ot instantiate our objects "right now".
__adrian
it doesn't. it's a way to set up instructions of how to do it.
retran
Bad_Advice, why not use a closure then?
Bad_Advice_Cat
Basically, this is just mapping things together.
retran
the "new" is happening somewhere down the line
__adrian
ofc it is
Bad_Advice_Cat
Yes, it is, in the background.
« prev 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 next »