« first day (1218 days earlier)      last day (3956 days later) » 

17:00
@rdlowrey would it make it possible to do something like gist.github.com/henrikbjorn/9e7495544b460361e6fc the key is that middlewares are created outside a thread.
user895378
HttpKernelInterfaces make me want to punch myself in the face.
:-)
why?
@rdlowrey well it is the most well known example for the middleware chain.
user895378
IMO it's a needlessly complex OO obfuscation.
user895378
And it leads to terrifically slow code.
user895378
17:04
If you look at the *SGI specs in other languages they look nothing like HttpKernel stuff
@rdlowrey everyone knows that OO means obstacles & obfuscation :p
@rdlowrey because of the composition being done?
user895378
All you need for a request? A single associative array. PHP provides that for you in the form of $_SERVER. Obviously the global mutability of the superglobal abstraction is unfortunate. But you can easily work around that.
@rdlowrey specific example?
@rdlowrey Agreed.
user895378
17:06
Request = $_SERVER
Response = [$body, $status, $headers]
user895378
This is all you need.
user895378
Look at WSGI
user895378
And PSGI
@rdlowrey eih, structure isn't bad... having a struct/class instead of an array is good as well
Hi guys!! I want to echo only the id of the selected product. How can I achieve it?
Thanks in advance
17:08
@bShah When you go to the grocery store do you also just walk to the counter and say: "Hey I want food! Thanks in advance."
user895378
@ircmaxell Structure isn't bad. But I'm on Rasmus island in this area in that I think PHP already provides any structure you need for requests. And any structure you need for responses requires nothing more than an indexed or associative array.
eih, not sure I agree there
user895378
It's good enough for python. WSGI is certainly a success.
@PeeHaa No!! What are you trying to say. That I just entered no greetings no introduction just started to ask question. What do u except?
user895378
I don't see the benefits of the extra structure coming close to outweighing the huge number of superfluous userland method calls that result from the extra layer of abstraction.
17:10
who's talking about huge number of method calls?
user895378
I am.
Damnit didn't get history
I'm talking about a struct... Something which can give static analysis hooks. Something which can provide some safety. Something which can provide trusted polymorphism
class Response {
    public $body;
    public $status = 200;
    pulbic $headers = [];
}
So all that needed to make me feel i need to go and study CS is a gist :p
@bShah Asking a question without introduction is okay; asking a very, very vague question and seemingly expecting an answer without any further information is... not.
user895378
17:11
Oh, I totally agree with that. My comments about arrays should be considered synonymous with object structures.
user895378
My issue with the HttpKernel is that it doesn't work that way.
I am sorry guys. This is really my first time in chat. I do not know.
user895378
It obviously enforces tons of unnecessary method calls because ... well that's just how interfaces work
Well...
One reason for that is people are treating a data structure like a logic unit
a request is fundamentally a unit of data. Not a unit of functionality
How I would do it?
I was considering building an app on top of HttpKernel but it just feels like they took the abstraction to the nth degree. And I feel like I sometimes take objects and interfaces too far but they went way extreme with it imo.
17:14
interface Response {};
class NormalResponse implements Response {
    public $body;
    public $status = 200;
    public $headers = [];
}
user895378
I'm totally on board with you on that.
Response as an interface becomes less about enforcing type, and more about enforcing intent
user895378
My issue stems from people treating http messages as behavioral things and not as datastructures
@rdlowrey: then let's create a kernel that makes sense...
user895378
lol that's what I've been iteratively working on for the last year (interspersed with lots of other things ofc)
17:16
@PeeHaa just what i was thinking :)
@ircmaxell IIRC that isnt "that" far from what HttpKernel / HttpFoundation does?
@PeeHaa not because it's a standard, but because it's clean
The sad thing I that I agree with both of them
17:17
@HenrikBjørnskov the standard kernel has shit-tons of methods and "bundle objects" etc
I am trying to make rating system of the products. To rate the product I need the product id only to store again in another table i.e. rating table. I am not able to get the selected product's id. What can be the select query to get the id of the product. I need only id.
@ircmaxell I know I know. Still... :)
@rdlowrey then put it out! The kernel part at least ;-)
@ircmaxell thats the package it is in, the interface only have HttpKernel and dependes on request / response?
user895378
I have too many projects going on at once. I need to stop doing php-src things and start finishing my own work.
17:18
@HenrikBjørnskov how do you get a request var from the request?
So the real problem is that the single interface isnt in a package on its own with Request / Response structs?
\o/ yay I just got offered a junior position by a recruiter!
@ircmaxell im sure you know $request->get($name); if you are looking for the $_REQUEST equiviliant
@HenrikBjørnskov under the hood, how does that work though? You need to go trhough IIRC 3 or 4 levels of indirection to get to the variable
@PeeHaa better than getting offered frontend work based on your linkedin. Got a cisco recruiter calling a little while back.
17:20
:)
user895378
Hmm ... do we think allowing the following is a terrible idea?
user895378
$ctx = stream_context_create(['ssl' => [
    'cafile' => 'http://curl.haxx.se/ca/cacert.pem'
]]);
user895378
Reference bug #65538
@PeeHaa: Not sure what's causing that.
@ircmaxell you mean the parameterbags yeah, Request::createFromGlobals();
17:20
@rdlowrey The http is pretty horrible
;)
Yo dawg let me get the pem file over a compromised connection :P
user895378
@PeeHaa What about allowing phar:// specifically as Sebastien mentions in the bug?
Hey guys i'm just wondering if there is a better more efficient way of doing these JSON pull currently I just call each function where I need the text,
user895378
@PeeHaa lol I know right
@rdlowrey yes. supporting ca files from arbitrary HTTP contexts is horrific
user895378
And phar:// how do we feel about that? I'm not sure that's even safe because couldn't the phar stream be chained to something else like http?
17:23
at some point you need to let users shoot themselves in the foot
at the end of the day, I'd support all stream interfaces (since it's hard to white-list), and then document the heck out of it
Documentation for it "Dont do stupid shit!"
user895378
Well I've implemented the functionality locally and it works fine ... but I'm wondering if it's worth doing because of the potential for people using something like the http:// example I posted above
@rdlowrey That would mean somebody would deliberately have to do that right?
user895378
Yeah ... basically I'm just asking if it's a feature worth adding even though people could do seriously stupid things with it
distributing certs in phars is a very valid use-case
user895378
17:25
Yeah, I thought so too ... That one in particular would be really useful.
@ircmaxell composer could use that i think.
user895378
Of course, if you're using a phar you could just write it to a temp file as well ...
@rdlowrey true, but that's dirty as well
user895378
So do we think it's something I should PR and ask about on the list?
I would
user895378
17:28
I'd also need to add some check to make sure you aren't using an encryption wrapper in your cafile path because that would infinitely recurse
user895378
'cafile' => 'https://lulz'
that's perfectly valid, as long as it's a different context (which it should be)
user895378
I need to test that specifically ... I may have the logic tangled up in my brain
user895378
@ircmaxell I'll ping you for input at some point in the next few days once I have a patch branch up on my fork
17:32
Can someone clue me in to how template files work when writing a cms (as a beginner in PHP)?
I assume you direct all requests to a file that handles the request and includes the template file based on the requested url?
@BillyMathews Yes
What do people think is more powerful? Lots of events or something like doing composition where it is also possible to stop the defaults and drop the chain?
@HenrikBjørnskov a mixture
like have a middleware that uses the EventDispatcher and have both?
17:35
Well, some problems having a chain-of-responsibility pattern is better. Some, having pure events is better.
I have the same impl for both Client and Server, having BatchServerMiddleware and BatchClientMiddleware is annoying my eyes :)
JS does this with a mix of both (event.cancel() and event.stopPropegation()
yeah
the middleware is easier to test i think. There is less paths to go through
user895378
I've struggled with how to standardize cancellation in non-blocking libs ... when distributing work to threads it's easy because I can just kill the thread and forget about it. With non-blocking libs this kind of thing may or may not be possible depending on whatever the implementation does internally.
@rdlowrey Well, are you using promises?
17:38
have thought about combining the middleware for Client / Server and give a "direction" to the call
user895378
A derivation, yes. But a third-party lib fulfilling the promise won't necessarily clean things up in the event that a promise is rejected.
clean things up? what needs to be cleaned up (not sure what you mean)?
user895378
Like if I use a third-party non-blocking DB lib and I tell it to cancel some task that's running how do you know that it didn't go ahead and write something to the DB. I guess this sort of thing is the lib's responsibility (e.g. transactions) though. So I might be worrying over nothing.
Noooo....
not what I mean
Only the handler can cancel, not external
user895378
I agree that external cancellation is very problematic. But I've kind of had to learn that myself (the hard way) :)
17:42
:-)
what is the cvpls thing?
And there's a difference between cancelation and rejection. External rejection is trivial. cancelation is much more problematic, which is why I see it as only applicable directly to the callback that's currently being executed...
@HenrikBjørnskov Click on the Docs in the star ;)
user895378
@HenrikBjørnskov the gets some truly awful questions. cv-pls helps to limit the most egregious of these :)
17:45
smart :)
evening :)
holy crap... The vocals are a little... well, wrong emotion, but amazeballls
10% of the world’s programmers are in China
1.4% of our visits come from China
Only 4.8% of our visits come from China, Japan and Korea combined
So, if the data tell us that we’re getting roughly 80% less activity from Asia than we should in the absence of language constraints,
Statistics #fail
The SE people are making such stupid changes. Even more than normally I sure this is just the beginning of the myspace era for SE
ted
ted
O_o
17:57
My opinion: what's wrong with having a common language? The internet is a step towards unifying the world. If dealing with a common language is part of that, AWESOME. Even if it wasn't english, common communication methods are AMAZING and freeing. Why the heck would wouldn't we want to embrace that?
ted
ted
+1
@ircmaxell Yes agreed 100%. And what they are doing is doing the exact opposite by fragmenting in the hopes of getting moar moneyz
you shouldn't need to have that common language to program, but the benefits of having it are quite clear and demonstrative.
user895378
I am agree with all.
Hey @ircmaxell how's your new job :D?
17:59
amazing! :-D So far at least
Good to hear :)
When documenting an API would you prefer the Foo::bar() or Foo:bar(void)?
Foo::bar()
@PeeHaa what programming language?
I think, but I am asking for PHP atm
18:03
Foo::bar() unless it has a specific meaning in the language.
What do you mean by that last part?
I don't like seeing void, pretty much anywhere...
ted
ted
@ircmaxell, great video
^^ Those vocals are amazing...
user895378
@ircmaxell so are you against @return void annotations? I seem to go back and forth on this one.
18:06
@rdlowrey yes, it's explicitly telling me what's already implicitly communicated
user895378
Makes sense. I think we both agree that code should be readable enough that the comments are unnecessary.
Well, I'm less talking about comments, and external documentaiton (generated or no)
like I'd never reject it in a code-review, but I don't care for that style
@DanLugg haha ok
but whatever, there are more important things to worry about. The only big stance I will take is: pick one way and stick with it. Don't do 1/2 the code base one way, and the other 1/2 a second, and the third 1/2 a third way...
@ircmaxell "do 1/2 the code base one way, and the other 1/2 a second, and the third 1/2 a third way" is a great description of how people perceive php.
18:15
@BenjaminGruenbaum the irony there is that it's the way people do everything though
I got in an interesting discussion at work about Java. I made an off hand remark that I can't stand it, and some one jumped in to defend it
as it turned out, he had my very same reservations and dislikes, and that it was just "hate how most people tend to use it"
which is the same with everything. Perception is usually biased based on what you want to see, not what is there
when someone looks at PHP, they want to see a pile of shit, so they do. They ignore the awesome things people do with it and focus on the shit. When that same person looks at the language they like, they ignore the shit and focus on the awesome things people do with it. Perception bias.
I think that as tl;dr - people like justifying their choices to themselves and others.
it's deeper than that though
their choice biases their perception of other choices
so it's not just justifying. It's that they really believe it. Because based on all of their perceptions, it's true
it's a really hard thing to get by, and often you never do...
but either way, I'm off, laterz
user895378
18:24
@ircmaxell later
18:40
Can php consider as framework instead of language. I remember teresko saying that PHP is web framework
God no. It's just mostly abused as such one.
@BasicBridge E_SUBJECTIVE
It's origins are definitely as a web framework, but a web framework for C
@DaveRandom Ok
yay people it's finally beer time again. laters
ololol it's ircmaxell
18:45
@BasicBridge Nowadays though... it's highly subjective. I know @rdlowrey would shoot you for suggesting it's not a proper programming language, and I'm largely in that camp
goddamnit EVERYWHERE I GO
ircmaxell: it's StoneCypher
@PeeHaa Enjoy. Bring on back for me :-)
@JohnHaugeland Yeah we have tried every trick in the book to lose him without any success ;)
@JohnHaugeland He's gone, I believe. Also you can @notify people in chat
some hilarious rando noob dragged me in here because they think PHP is a web framework for C
18:45
@JohnHaugeland yo
@JohnHaugeland lulz
/hides
5 mins ago, by Basic Bridge
Can php consider as framework instead of language. I remember teresko saying that PHP is web framework
;)
they actually think this chat is going to support them in that obvious wrongness, and also, that if a chat actually did support them in something that obviously wrong, that i would suddenly think it was right
@DaveRandom will do! ciao
18:46
peehaa: yes, that appears to be the one
user895378
The PHP web SAPI was created as and still very much is a web framework. But PHP itself is a real language. Whether it's used correctly depends on the programmer.
@JohnHaugeland I believe what I said is that it started as one of those, not that it is one of those
but it didn't.
php-fo was not a framework.
go look my name up in the SVN commits if you need a reason to sit down and listen
C'mon, it kinda did. It was just Rasmus's little DSL at first
if you argue that php-fo was a framework, then literally fucking everything is a framework
it did not offer any of the facilities that distinguish frameworks from generic libraries
this is retarded and you should be ashamed of yourself for falling for it
this is one of those things where "it's a framework because it's got three things and it's on the web"
translation: you don't know what a framework is
user895378
18:48
Honestly, who cares about the semantics of this anyway
me, i got dragged into chat by some facebook nincompoop and i want to make sure he doesn't do this to anyone again
@JohnHaugeland: we've worked very hard to try to keep this place civil. We've failed at times, but please don't be rude, abusive or condescending. We can try to be civil at least.
user895378
lol
ircmaxell: that's a change for you
ircmaxell: you used to love this stuff
weird.
ok
@JohnHaugeland Correction, I don't care what a framework is. And also, I refer you to this:
7 mins ago, by DaveRandom
@BasicBridge E_SUBJECTIVE
18:49
@davera
@daverandom: don't confuse "i took a position i cannot defend" with "this is subjective"
@daverandom: if it actually was subjective and if you actually do believe that, then your earlier affirmative position was inappropriate
I want the too localized cv-reason back :-(
Wow. Just wow. I'm going to go out for a beer, grab some popcorn on the way back and have fun reading back the transcripts of @JohnHaugeland yelling at everyone :-)
Now I'm really out drinking
@daverandom: it turns out this actually is well defined; authority doesn't come from certainty, nor does it come from the ability to quite other people who also picked an argument they can't handle backing away from it.
@daverandom: one of the problems with internet chat is that it gives people the expectation that looking certain is better than knowing what they're talking about, or presenting themselves in a way that people with more experience can actually help them
@JohnHaugeland You are StoneCypher?
@daverandom: if you need help understanding why that's bad, ask ircmaxell about shield some time
@ni
@nikic: I am.
sorry about all the fragment lines; i keep hitting return to complete by habit
18:52
Why is static $something = $this->expensive() not allowed?
in a method
@JohnHaugeland Dude, wtf... I'm happy to listen to other people's points of view and adjust mine as appropriate when they make good coherent points, but I prefer not to be yelled at. I am indeed not an authority on things...
henrik: because statics are outside an instance, and you're attempting to call something on an instance
I'm not sure where I know you from, but my mind associates the name StoneCypher with "troll"
@daverandom: you attempted to take the position of authority, and you absolutely have not been happy to listen to other people's points of view.
@JohnHaugeland no thats not why, i added it was in a method :)
18:53
@nikic: that's nice
@nikic: I know where it comes from, and I'm ignoring you to save myself your drama
@HenrikBjørnskov because static declarations are just like constants, they must always be values, not expressions. That's why you can do array(), but not a function call or addition...
henrik: my mistake.
@JohnHaugeland Where? I'd like to know...
i find it weird i can set the static after
18:55
@HenrikBjørnskov all it means is that the variable is kept between function invocations (all function invocations share the same value for it)
@ircmaxell It makes very little sense, actually
static could just as well use a dynamic initializer
@NikiC I'm not arguing that. I'm just describing how they are implemented today
after all, you can assign it a dynamic value afterwards
@ircmaxell yeah, I know ;)
go for it! make the patch! Yay for progress ;-)
18:58
meh ^^
you know I'm too lazy for that :P
I just like to complain
BTW, you really should come work for the big G... I think you'd really shine :-)
I'm off, later all
@JohnHaugeland Isn't that essentially what you are doing? Regardless, I didn't come here to be shouted at. I'm not infallible and I'm considerably less experienced (intelligent?) than some of the regulars here but I'm also not a total f*ckwit, and neither am I particularly argumentative, and as a result I am now leaving this conversation until it becomes more civil and less citation needed.
19:12
why chrome is buggy when am using ob_start() and ob_flush()?
@Mr.Alien define "buggy"
'@DaveRandom check this out projects.decodingweb.com/system
now enter anything crap login and press access
firefox will redirect and throw you an error... chrome won't
@Mr.Alien I'm not sure but that can be javascript trouble
@BasicBridge PHP, header() + session error
and session error means I throw errors using sessions
@Mr.Alien Got some pretty epic JS errors, I have to say
Like, a shitload of TypeError: Cannot set property 'innerHTML' of null
Also my FF is playing up, what happens when you do it in FF?
(like, what's the error message you get)
19:18
@DaveRandom won't matter as of now, cuz I've used all the scripts in include, so it throws those shitty errors
nah, no error
see what I am doing is
if login success, header -> dashboard, works well in chrome as well as firefox, it throws me to dashboard
but if login fail.. $_SESSION['error'] = 'login failed'; header('location') same page, exit;
so here, chrome doesn't redirect
when I press f5 it shows me resend box...
whereas firefox redirects, shows the session generated error by me, I unset once it's thrown, so when I press f5, the error is cleared up as I am using unset()
@Mr.Alien your Location header is empty
Basically you redirected to nowhere
Obviously ff interprets this as the empty uri (self-referential), where Chrome (correctly) does not
@DaveRandom nah nah, I just threw you an example, its header('location:'.base_url('r')); <--- that's my function
it works great on ff
@Mr.Alien Yeh but I'm telling you what I actually see in my browser
19:22
@DaveRandom you see that in chrome right?
I guessed your code wasn't just header('location') because I know you are not an idiot :-P
HTTP/1.1 302 Moved Temporarily
Date: Sat, 15 Feb 2014 19:20:45 GMT
Server: Apache
X-Powered-By: PHP/5.5.6
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma: no-cache
Location:
Keep-Alive: timeout=5, max=75
Connection: Keep-Alive
Transfer-Encoding: chunked
Content-Type: text/html
^ that's the response header Chrome debug tools are showing me
lol, nope, it's written very nicely, infact I've ported most of my code in functions this time, I hardly have any lingering code around...
than how it works on firefox, lets ask madara to test, @MadaraUchiha you free for a while?
Hmm?
What's it about?
@Mr.Alien I imagine moz are interpretting the empty location as the empty URI (self-reference) and refreshing the page
test, will just take a min
@DaveRandom may be...
19:25
While that is valid in terms of a URI, it's not valid in terms of HTTP
it should work though, I will show you the function I made, wait
Actually, the vast majority of Location: headers that you ever see are not valid in terms of HTTP, people very rarely use absolute URIs for redirects within their own application :-(
@DaveRandom am using relative..
not sure ^^^
turns out that it's absolute
function base_url($mode) {
        $protocol = strtolower(substr($_SERVER["SERVER_PROTOCOL"], 0, 5)) == 'https' ? 'https://' : 'http://';
        $path = $_SERVER['PHP_SELF'];
        $path_parts = pathinfo($path);
        $directory = $path_parts['dirname'];
        $directory = ($directory == "/") ? "" : $directory;
        $host = $_SERVER['HTTP_HOST'];

        if($mode == 'e') {
            echo $protocol.$host.$directory;
        } elseif($mode == 'r') {
            return $protocol.$host.$directory;
and this
function redirect($redirect = null) {
        if($redirect == null) {
            $url = $_REQUEST['REQUEST_URI'];
        } else {
            $url = $redirect;
        }
        header("Location: ".$url);
        exit;
    }
but on the login page am using header('location:'.base_url('r'));exit;
@Mr.Alien Most basic debugging, replace that line with var_dump(base_url('r'));
@DaveRandom I get the URL of that very page, so it's perfect...
19:32
There are a few issues with the function btw, but I have to go make dinner so I'll explain them in 15 mins if you're still about :-P
@DaveRandom take your time :) am just debugging that
19:49
@DaveRandom fucking firefox didn't threw me undefined error for $url = $_REQUEST['REQUEST_URI']; fixed it, uploading it on server now...
@Mr.Alien How should browser throw/show error for that? oO /me misses context
@Leri I meant php didn't threw me any error in firefox, but it did in chrome.. I have no idea why is that so
@Mr.Alien Oh, it was sent in header. I guess chrome's behavior was correct.
yes, on the other hand, ff redirected without throwing me any php error, I don't know why ff didn't threw any error..
@Mr.Alien Should be $_SERVER['REQUEST_URI'] ;-)
20:00
@DaveRandom hah yap, fixed already :) thanks though...
I'm using a weird API with a method that returns a string which contains http headers and the response body. Looks like this: http://pastie.org/8737104
What's the proper way to pick apart the headers from the response body?
Just split on first new line?
(double new line)
Note that you should basically never use PHP_SELF for anything, ever
@DaveRandom I use that for retrieving the basename, though, thanks for that, time to alter the function now :D +1 ... thanks again :)
@WesleyMurch I generally preg_split('/\r?\n\r?\n/')
There are some HTTP servers that misbehave in this respect, and there is a BC spec in 2616 (I think, certainly in older specs) that you should tolerate a missing CR
Stupid drunk fingers
Thanks @DaveRandom I'll just do that, wasn't sure if there was anything built-in. So in the headers themselves there will never occur a double newline?
20:05
@WesleyMurch No, the definition of the thing that separates headers from body is "an empty line"
Perfect, thanks. Moving on... have a good day guys.
/**
 * @param string $head
 * @return array
 */
private function headerStringToArray($head)
{
    $result = [];

    foreach (array_slice(preg_split('/\r?\n(?=\S)/', $head), 1) as $header) {
        list($key, $value) = explode(':', $header, 2);

        if (!isset($result[$key])) {
            $result[$key] = [];
        }

        $result[$key][] = trim($value);
    }

    return $result;
}
@WesleyMurch ^ if you want the headers as well
(as an assoc array)
Also should probably throw a $key = trim($key) in there as well
Oh also that cuts the first line off, assuming it's an HTTP request/response line
and for the record, said "strange API" probably uses ext/curl underneath with the CURLOPT_HEADER set to true
he left already
He'll be back. They always come back.
It's my magnetic personality
:-P
lol :D stars..
20:14
@DaveRandom Or SO's notification system. :p
@Leri it fails many times to notify
I've never experienced that. ^
I did, many times, I can't post that on meta cuz it's random... though it's less now... it also misses the rep count, it triggers if someone other votes ... than it shows the calculated count on the top
20:48
Well, hello
I just messed up, lol
I accidentally typed in `bind clear` (I was going to start the bind server but remembered that it was the keybinding tool, tried to ctrl+c and then type clear)
Now my c key doesn't work properly in ssh...anyways, off to the manpages
Dangit
Everything on the internets either for mmorpg keybindings or the mount command
Any ideas how to implement a method that returns the number of digits in a supplied integer without using any local variables using recursion?
strlen perhaps?
It must be solved using recursion
Homework? ^
@Leri Might be, I don't see any reason why you can't pull it from strlen if it's an integer
20:58
@Leri I've decided to do a computer science exam and that's a question that came up previously
It has to be something got to do with dividing by the 10
$num = 12345;
$digitcount = strlen((string)$num);

I don't know whether the (string) part is necessary, afaik type conversion in PHP is automatic anyways, added it in there more for good luck.
Never researched recursion before
Sometimes even simple recursive methods mess with my head thinking how they will executed on the 2 and 3rd invokation

« first day (1218 days earlier)      last day (3956 days later) »