« first day (676 days earlier)      last day (4272 days later) » 

3:00 PM
@tereško When do routes fire? Only when a direct route isn't found? (i.e. the <controller>/<action> pair doesn't exist)?
Or even before you check?
 
the notations are transcribed in regular expression
if expression does not match , you try next route
if expression DOES match , but some optional values are missing , you use the defaults for those fields instead
 
hey @LeviMorrison, you here?
 
order of routes matters, right? just like .htaccess rules, "deeper" (don't know the exact word) ones must be above...
 
@tereško Oh, now I get it
So in that example, /login and /register map to /authentication/login|register
 
you are not mapping to URL but to classes
but yes , it will map to authentication controller , with either login of register method
 
3:05 PM
@tereško Yeah, I used URL to illustrate, but I get it
 
@webarto yes .. i tried out variant where routes had priority parameter , but it turned out to be useless
@Truth , the problem , which is solved this way is that the regular expression for routes are quite unreadable
 
@tereško yes, personally, no need for that, I think it would just add up to confusion, you can differentiate visually when you see the code...
 
it is easy to make a mistake , and not be able to find it or even see
 
@tereško Yes, I can see
Now a different question, if that's the case, why would you even need to use RouteBuilder or Route objects?
Why not read directly from the array?
 
what do you mean ?
are you suggesting lazy loading for routes ? (which actually is not such a bad idea)
 
3:07 PM
@JordanRichards clearly no ;)
 
@NikiC yeah :L
 
@tereško Why not use the config array you got from load_config directly?
 
@JordanRichards But if you have a general question, just ask it ;)
 
i still cannot understand the question
 
@tereško You have the config array, which is the json_decoded version of the configuration file
 
3:09 PM
the array is just that , an array , it does not contain ant regular expression
 
@NikiC Thanks :) Yeah, I just like talking to Levi, he's a good friend. He also explains things to me when I don't understand them.
 
the data from JSON has to be turned into those expression
 
@tereško What does the Route object contain?
other than that regular expression?
 
defaults , and also own name
 
(just making sure I get it myself)
 
3:11 PM
route applies a pattern to URI and extracts values , then it adds defaults
public function route( $request )
{
    $uri = $request->getUri();

    foreach ( $this->pool as $name => $route )
    {
        if ( $parameters = $route->getMatch( $uri ) )
        {
            $this->currentRoute = $route;
            $request->setParameters( $parameters );
            return;
        }
    }
}
 
okay, understood
 
and yes , the $uri = $request->getUri(); line must go .. it's another flaw
 
then you check if controller exist, if action exists, and invoke action... ?
 
no
 
3:14 PM
moar
 
lol
 
for that i use structure lie this in bootstrap , to wrap the controller instance
basically there is a try-catch block with catches accessDeniedand notFound exceptions , that are generated either by ACL or class loader
this way i can handle "not found" and "access denied' situation without redirect
i hate when i have bookmarked left open in tab restricted location , and loose the URL
 
ah, never thought of ACL in there... funny how 1 answer is accepted besides yours and hakras...
nice noice
 
yeah , and none has upvoted his answer , even though it is good one
SO rule of rep: "has code, will get upvotes"
 
@tereško So "notation" is transferred into a regular expression, how do you maintain the information about which expression is for which part? (resource, action?)
 
3:22 PM
recently experience that law myself : stackoverflow.com/questions/11542153/…
@Truth uno momento ..
/(?P<controller>[^\/\.,;?\n]+)(:?\/(?P<action>[^\/\.,;?\n]+))?/
i use this form of regular expression ... and that is another part i need to fix ( the delimiters should not be / )
 
I thought about named groups
Though wasn't not sure how to implement
 
the value from conditions , if they are set, replace the [^\/\.,;?\n]+ bit
this is what you get from /:controller[/:action] notation
 
I've been dealing with OOP and MVC and whatever for so long, I've forgotten the basics
@tereško For the sake of consistency, what's the difference between controller and resource?
 
"resource" is name for both controller and view (just different namespaces)
i use 1:1 relation between them
hey guys , a serious question : do you have any ideas about what snacks one can eat while coding ?
 
3:37 PM
@tereško hehe imo anything goes as long as it isn't sticky
 
something that does not leave grease all over the place
i am about inch from starting to eat snacks with chopsticks
 
it is not healthy :P
 
@tereško Donuts, peanuts
 
both are greasy
 
@tereško I tend to eat cereal.
 
3:42 PM
i have only fruit & grain muesli
 
Good morning all
 
@tereško Sunflower seeds are nice too
 
@Greg , any suggestion on "developer food" ?
 
That's all I eat
 
@Truth , only you end up with seed-shells all over the place
 
3:44 PM
@tereško You put the shells in a second bowl?
 
Seriously though, what kind of "developer food" are you looking for? Are you after daytime snacks or full meals to keep your levels topped up?
 
@tereško You can use spoon :P
 
@Greg , must be an american thing, because to me it looks like a logo for washing powder
3
 
@Greg Mountain Jew
 
@Greg , something to keep my jaw busy with while i am thinking and writing
 
3:46 PM
@tereško That is one of the single most appropriate comment I've heard all day.
 
$notation = ":controller[/:action]";
$notation = preg_replace("/\[(.*)\]/", "(:?$1)?", $notation);
$notation = str_replace(":action", "(?P<action>[^/.,;?\\n]+)", $notation);
$notation = str_replace(":controller", "(?P<controller>[^/.,;?\\n]+)", $notation);
echo $notation;

//(?P<controller>[^/.,;?\n]+)(:?/(?P<action>[^/.,;?\n]+))
@tereško looking good
(And I still can't believe I hadn't thought about that myself)
 
the [ ] are for optional parameters
 
@tereško forgot the ? there
there :)
 
it will blow up in 10 .. 9 ... 8
 
3:59 PM
:5040695 How come? It's practically identical to the pattern you've shown
(I get this now: (?P<controller>[^/.,;?\n]+)(:?/(?P<action>[^/.,;?\n]+))?)
 
additional conditions ?
 
@tereško Haven't started on the actual conditions yet, just the notation part
 
well ... i guess it will be just fine
only keep in mind that the segments are not always the same
 
What do you mean?
@tereško :action may not always be called :action etc?
 
action might not always be in the notation
this is where the defaults come in
 
4:04 PM
@tereško But if action may not always be in the notation, it shouldn't be in the pattern either
 
yes
 
hello..im here again.hahaha
 
i want to insert multiple values in table, values are inserted by using $_REQUEST variable. When i run script, and i get request values then i can insert only once because there is only request to server. After a lot of search, i am sure it is not possible in request case, is there any solution?
 
say what
 
@shihon Where are the multiple values coming from?
user input?
 
user895378
4:19 PM
@tereško The reason why that code took a long time to finish is because all HTTP 1.1 connections are assumed to be keep-alive unless Connection: close is specified by one of the parties. Because the connection isn't closed, feof won't return true until the connection is actually closed.
 
user895378
So what you have to do for HTTP transfers if you don't want to close every connection after each request is setup a state machine to determine when each message ends according to the guidelines set out in RFC 2616 Section 4.4
 
@Truth: yes through user input, in actual there is a application interaction with php script, so users are handled by application
 
user895378
Headers are always terminated by the first occurrence of 2 x CRLF, so fgets makes that simple for blocking streams (it's a bit trickier for non-blocking). From there you determine when the message is complete from the rules laid out in the link above.
 
user895378
If you're dealing with redirects it may be worth validating the Location header unless you know it's going to be correct, because people often specify a relative URI path in there even though it's supposed to be a full absolute URI. When that happens all you can really do is assume the path applies to the same host as the last request.
 
Should i store fist ten requests in an array and then re run php script to insert multiple values, but in this case script execution is double for me and this case is no more worthy in a millions of insertion
 
lol
 
hehe
 
@tereško sorry for the late reply, but dried fruit, nuts and fibrous snacks are good to keep your energy levels up during the day
 
user895378
@tereško So, since that was a HEAD request, there obviously should be not entity body returned. In such a case you know you can break out of the loop as soon as headers are finished like this:
 
user895378
4:31 PM
while (!feof($handler)) {
    $line = fgets($handler, 1024);
    echo $line;
    if ($line == "\r\n") {
        break;
    }
}
 
user895378
If feof returns true before that you know there was a network error before the transfer finished.
 
(>’.')>=O____l_*__O=<(‘.’<)
 
@webarto ?
What's the supposed to be?
 
user895378
ping pong!
 
4:36 PM
:P
 
lol
 
Drop Windows XP and 2003 support.
:(
 
there will be a way to use it without problems I think
it will only be, well, unsupported, meaning you don't have right to complain
and XP is not good on newer machines
 
@Donut , and running PHP on windows in general is quite questionable
 
I love my localhost and my localhost loves me
 
4:41 PM
it is OK for testing, and you can even hack it up for development (ported unix tools and what not), but for production, no way...
 
@webarto ☉_☉
 
user895378
I've never had a ton of success with PHP on windows ... Also, I don't think XP can use more than 3Gb of RAM even if you have 128Gb in your machine
 
@rdlowrey nah, you have to use a buggy 64 bit XP to use more than 4GB memory (including your graphics memory)
 
@rdlowrey XP 32 bit version limits process to allocate 2GB memory iirc
 
user895378
Yeah, I knew it was something silly like that :)
 
user895378
4:44 PM
That said, I do like my XP VM from time to time :)
 
Limit on X86 - 64GB
there is a sort of hack to enable that on XP, but there is no point in that...
 
You mean that /3GB switch which sucks?
 
user895378
If I ever had a machine with 2TB of ram I might wet myself.
 
I said the same thing about 200mb...
 
there isn't one in form of PC I guess...
192GB IIRC
 
4:50 PM
@tereško what can you say about kohana?
 
@ircmaxell :P
@JoeySalacHipolito it sucks
 
My first personal PC had 640kb ram... old-computers.com/museum/computer.asp?c=531
 
@JoeySalacHipolito , bad practices , no documentation , good community , good code comments
 
how about their understanding about mvc?
i see...
thanks... how about cakephp?
 
The Commodore 64, commonly called C64, C=64 (after the graphic logo on the case) or occasionally CBM 64 (for Commodore Business Machines), or VIC-64, was an 8-bit home computer introduced in January 1982 by Commodore International. Volume production started in the spring of 1982, with machines being released on to the market in August at a price of . Preceded by the Commodore VIC-20 and Commodore PET, the C64 took its name from its of RAM, and had favourable sound and graphical specifications when compared to contemporary systems such as the Apple II, at a price that was well below th...
So much sweetness
 
4:53 PM
iPad is will be the new Commodore in few years
 
@JoeySalacHipolito horrible practices , sensible documentation , fanboy community , comments only in docbocks
 
hahahahaha..lol @ horrible practices...
 
I had a few C64's. But I don't consider that a PC, as it wasn't really general purpose...
 
anyway, thanks for the input guys.. gotta continue reading on...
 
reading opinions won't get you anywhere, test and see for yourself...
 
4:56 PM
@JoeySalacHipolito , you should focus more on researching OOP. Go through the list of lectures here .. when you are done then you can get back to researching php frameworkss
 
@tereško i've watched all that lectures..hehe..i kinda did not understand..hahaha..as you said before, programming literature is really full of jargons, that i must understand..hahaha
pretty tough to understand though
 
well .. then you start from first one and look up in wikipedia and c2 every term you do not know
when you understand everything that was said first lecture (you do not need to agree , just understand) , get to the next
 
@JoeySalacHipolito If you learned anything from the series, then rewatch them. Since you understand more than when you first watched them you will be able to understand more.
 
yeah, also, if i can see real codes, i can understand it very well, i think that is how i learn, when i try, try and try . .
yeah, i've been watching them the whole time, hoping i can understand each, piece by piece
 
in that case you should write some code and submit for a review in this chat
.. if you are able to handle harsh criticism
 
5:01 PM
yeah, criticisms are welcome . .
 
well .. then write a guestbook (or maybe, a blog ) application and push it to github
 
i hope you won't get annoyed to me, i might ask senseless questions...
senseless for now
but i hope my questions will become sensible in the future
 
oh .. another thing you can write : a simple application with login, registration and and saveable textarea, which is usable for logged-in users
 
Is there a way to see how close you are to a certain badge?
 
@LeviMorrison not really
which badge you are aiming for ?
 
5:05 PM
yeah, i am thinking the same. login, registration,
 
@tereško Not really aiming, per se. More curious about silver PHP badge.
 
can you comment on this tutorial i've seen youtube.com/watch?v=GBuJXovvdWE&feature=plcp
 
@tereško Right, but I'm curious to see how close I already am.
Do I have 101? or 380?
 
you have 143
 
5:07 PM
@LeviMorrison: You have 143 for 90 questions
you need 400 for 80 questions
1000 for 200 for gold
 
@tereško Where do you get this information?
 
@LeviMorrison , did you open the link ?
 
Ah, I see.
Thank you.
 
/me 365 php × 375
I suck
 
5:16 PM
@JoeySalacHipolito a lot of bullshit , misdirection and not real info
 
hahahah.. okays, so i wont watch it...
 
github.com/php/php-src/commit/… is developing really funny
It turned into some kind of fag discussion
 
thanks a lot @tereško . . i'll watch over the videos you gave to me
i mean the links
 
stackoverflow.com/questions/12078198/… this one is questionable. the question is bad. so i'm voting to close. however it could be saved.
 
@NikiC is there a way to flag a user ?
 
5:20 PM
. . . SERIOUSLY?
1
Q: Finding maximum value from an array which contains positive integers and/or recursively nested arrays of positive integers

Mohammad Faisal IslamIf an array initialized as: $arr = array(array(141,151,161),2,3,array(101,102,array(303,404,606,555,789,array(1000,22,9999,array(9057,100000),522)))); Then the result should be: 100000 I have written a function to solve this problem but I need less bytes and less memory of codes. My Func...

 
@tereško should i watch the videos in sequence? accdng. to your post or no?
 
I didn't get the accept vote on that?
 
@tereško Which one?
oh, and hi @LeviMorrison
 
Some guy copy / pastes a manual example that is not very intuitive and beats my robust and lovely answer?
I hate . Noobs can't even recognize the better answer when it has more upvotes :/
 
btw, again, whats the mistake on r.je mvc tut again?
 
5:21 PM
@NikiC mekza
@JoeySalacHipolito the exchange between view and controller
 
@tereško You can report users for abuse on their profile, but not sure whether it is appropriate in this situation
 
$controller = new Controller($model);
$view = new View($model);

is this right?
 
there is term "verbal abuse"
 
@LeviMorrison I quit to answer a year ago... exponential influx of idiots everyday...
 
Why would they do such a thing?
 
5:24 PM
you are so 57 mins ago @Neal
 
@JoeySalacHipolito nope , it isn't
 
so whats the correction again?
 
@Neal It was decided that PHP's world dominance is implied, so there is no need to explicitly point it out in the NEWS ;)
 
$model = new Model();
$view = new View( $model );
$cotnroller = new Controller( $view, $model );
@JoeySalacHipolito , essentially this is how the parts relate
 
5:26 PM
@NikiC lol
@NikiC haha I wasnt here :-P
I just read the news :-(
 
@LeviMorrison I can smell from distance that OP is a fag
 
okay got it, i'll get back to mvc later, after my oop video lessons . . .
thanks...
 
user895378
@LeviMorrison lol
 
user895378
> For multidimenional arrays, this little snippet of code is found on the PHP docs (user contributed)
 
user895378
Should've gone with the blatant manual code snippet thievery.
 
5:32 PM
@LeviMorrison hey
 
can you rate this books
1. design patterns for dummies
2. OBJECT-ORIENTED PHP (Concepts, Techniques, and Code) by Peter Lavin
3. PhpArchitects guide to php design patterns by jason sweat

1-10
 
I should have downvoted him.
 
user895378
I just did. I have a low tolerance for "I pasted this from over here" answers.
 
user895378
You could eliminate 50% of new questions in the by forcing people to do some var_dump debugging BEFORE posting.
 
user895378
"Hey this doesn't work"
 
user895378
5:38 PM
"Did you verify that you actually have what you think you have in $myVar?"
 
LOL
 
user895378
"No, how do I do that?"
 
@rdlowrey you could make a canonical q/a on it
 
Turn on error logging. You explicitly turned it off. How can you expect to debug without it? — Levi Morrison 37 secs ago
 
@LeviMorrison Post your code as a User Contributed Note, then cite it in your answer.
 
user895378
5:41 PM
This renewed interest in answering questions for increased rep-itude is going to make me bitter.
 
@salathe I posted it as a user-contributed note last night because it seemed helpful.
 
@LeviMorrison Oh, then cite it in your answer and watch the upvotes roll in.
 
@SomeKittens I don't see any problems with his question.. — Samuel 1 min ago
BAH
(also: @salathe thanks for the regex fix)
 
@SomeKittens happy to help
 
5:50 PM
@LeviMorrison Uhm, why would you use stack-based recursion there?
 
@rdlowrey: I guess it depends on the language heh, in [c++] and [c], half the questions have answers that basically are copy-pastes the C or C++ ISO standard and they get the most upvotes
 
@NikiC I didn't NEED to. I do know that at least somewhat recently that PHP had poor recursion performance, so I avoided it. I didn't not think of using array_walk_recursive as @salathe did.
Besides, as a general rule I avoid recursive solutions if a stack-based one makes sense.
BST traversal? Probably will use recursion except when creating an iterator . . .
Of course, I doubt he'll have heavily nested arrays.
Also, if you are looking to rep-whore, don't answer questions from users with 1rep.
They probably won't 'accept' your answer nor upvote.
 
No love for substr_replace() :(
 
Out of curiousity I will do some basic and probably incorrect testing of my stack-based solution and @salathe's array_walk_recursive.
 

« first day (676 days earlier)      last day (4272 days later) »