« first day (1266 days earlier)      last day (3700 days later) » 

1:00 PM
@rdlowrey What if that something.php needs a specific message passed to it?
 
user895378
<?php $specificMessage = 'zanzibar'; ?>
<html>
<?php if ($loginSucceeded) { include 'something.php'; } ?>
</html>
 
user895378
problem solved
 
Makes more sense to create that something.php template in the view, bind the message, then bind that template inside the main body template or whatever
 
user895378
Nothing about the above code precludes you from doing that.
 
@David Then you need an abstraction over include(), like $this->loadBlock('footer', array('..of messages..'))
 
user895378
1:02 PM
View !== template
 
That's messy I think. So you are binding a message to a login box template which includes a message template but the message binded to the login box template in order for the message template to have access to the message. Why not just bind the message to the message template? That is where the message is meant to go
 
Template is a part of a View
 
user895378
There's nothing messy about using php as your template lanugage.
 
what I do is have include 'generic.head.php' and include 'generic.footer.php' then the body just goes in between
 
You need a separated class that deals with template blocks only
 
1:03 PM
@rdlowrey php was designed as a template language long ago (:
 
But you are putting variables in one template to get access to that variable in another. Why not isolate them and only give them variables they need
 
user895378
function($vars) use ($templatePath) { extract $vars; include $templatePath; };
 
The login box template has no interest in the actual human readable message but it has interest in the actual message template. The message template only wants the message
 
user895378
Uh, yeah, which brings us back to my original point:
 
user895378
7 mins ago, by rdlowrey
include '/path/to/file';
 
user895378
1:04 PM
Nesting templates inside of templates ^
 
Yeah you include a path to the message template file, are you saying hardcode the message into the message template?
 
user895378
include $variablePath;
 
user895378
This idea that it's impossible to separate your concerns without introducing a pointless DSL is misguided.
 
What about internationalisation?
 
user895378
What about it? Does presenting information in German mean variables stop functioning?
 
user895378
1:08 PM
My point is this: the only valid reason for using a templating language that isn't PHP is to get auto-escaping of your data. And even that can be done perfectly well without a DSL.
 
The message template could just be
<div class="<?php echo $type; ?>"><?php echo $message; ?></div>

Now let's say one of the form inputs is called message or type, when I bind my message and bind the form data (if there was a problem with the form) we have a clash of variable names doing it your way. If I keep the message template isolated in it's own scope I can keep the simple names of $type and $message for both templates
 
user895378
?
 
What don't you understand
 
user895378
if ($errorOccurred) { include $messageTemplate; } else { include $errorTemplate; }
 
user895378
No one said extract($_REQUEST) ... you can't just blindly do whatever you want and expect everything to magically work.
 
1:11 PM
Ok and how are you getting the error message to those templates
 
user895378
Quite obviously, if an $errorOccurred you will have also assigned an $errorMessage variable.
 
@David Yes, but it's passed in (by view inflater/creator/loader) so there's no hidden dependency.
 
user895378
No framework will write your code for you, no matter what it promises. You have to employ some logic yourself.
 
Word.
 
Especially validation and storage
 
user895378
1:14 PM
Each time my CPU fan turns on I get paranoid that the NSA is using my box to mine bitcoins or something.
 
@rdlowrey CPU can't mine well, so don't worry. :D
 
user895378
I don't discriminate against slow machines when building my botnets Yeah you're totally right.
 
@rdlowrey I don't like the scope of the templates being so wide, if you have one or a hundred templates they all have access to the same template variables. What's wrong with:

$login = $this->buildTemplate('frontend/login');
$message = $this->buildTemplate('shared/message');
$message->bind('message', 'Something went wrong blah');
$login->bindTemplate('message', $message);

Then in the login template file have this somewhere
<?php echo isset($template['message']) ? $template['message'] : ''; ?>
 
user895378
Define "so wide." I'm not suggesting anything other than what you've posted above.
 
@rdlowrey I don't use any framework or any special templating engines. I use two or three components from symfony.
What are were arguing about so?
 
user895378
1:17 PM
> I don't use any framework or any special templating engines. I use two or three components from symfony.
 
?
 
He meant full-stack framework
 
user895378
32 mins ago, by David
@Leri And having a Template class makes it very easy to nest templates within templates among other things
 
According to the second sentense
 
I use the session component and YAML? That is not using the whole framework to my knowledge. I don't use their httpkernel, twiggy thing etc
 
user895378
1:18 PM
My point is that having a template class makes it less easy to nest templates within templates
 
user895378
include 'templateFile.php';
... then in templateFile.php ...
include 'omgNestingTemplatesHere.php';
 
@rdlowrey But you have to set some sort of $everythingWentSuccessful or $everythingFailed variable and then check it's value to decide whether to include the template. The view is for presentation logic isn't it? Should'nt it decide whether to include/nest the template?
 
user895378
No you don't.
 
No I don't what
 
user895378
> But you have to set some sort of $everythingWentSuccessful or $everythingFailed variable and then check it's value to decide whether to include the template.
 
user895378
1:21 PM
You're doing the same thing in your approach but the logic is hidden behind a method call.
 
It goes in the view along with other presentation logic
 
Back. I missed some interesting shit
 
Keeping the template file even simpler
 
user895378
There is no "View" in a PHP web SAPI application.
 
@rdlowrey Please clarify
 
1:22 PM
What about the View you can DI into your controller?
 
user895378
20 mins ago, by rdlowrey
View !== template
 
Yeah, I mean.. the View that decides what Template(s) to render
 
@rdlowrey Yes I know and? I think it's pretty clear they are separate things
 
Earlier on we had a huge convo about difference between a view and a template :-)
 
user895378
2 mins ago, by David
It goes in the view along with other presentation logic
 
user895378
1:23 PM
^ then don't misuse the term
 
When in the view and doing some presentation logic like deciding what templates need to be selected, selecting what JS and CSS need to be linked, setting the page title, it makes sense to also setup the template nesting
 
user895378
You can't possible have an actual "view" in the MVC sense in a php web sapi application because the view can't interact with the model. It's one-way communication.
 
@rdlowrey This is not desktop MVC we are talking about but web MVc
 
user895378
22 hours ago, by rdlowrey
@David If you hear someone discussing MVC and the web in the same sentence it's highly likely that they don't know what they're talking about.
 
user895378
There is no such thing.
 
1:27 PM
It is obviously not really possible in the stateless HTTP but web MVC does exist
 
user895378
Example?
 
user895378
If it's not really possible how does it exist?
 
They are in much different environments so they will obviously differ
Can you not see I am saying WEB MVC
 
user895378
I can. And I'm saying WEB MVC is not MVC.
 
I'm saying traditional MVC is not really possible over stateless HTTP
 
1:28 PM
@David Evolution!
 
user895378
@David Quite obviously. So what is Web MVC and how is it different from MVC?
 
@rdlowrey The concept of the controller dealing with input usually from controls. The controller updating the model layer, the view fetching it's data
 
@David How's that different from MVP?
There's no need to make up terms like Web MVC, when there already exists one and is more common.
 
MVC to Web MVC is like Java to Javascript :P
 
user895378
Look. I don't care about these pointless architectural abbreviations. None of them make one iota of difference and it's a waste of time to try and say "this one is better than that one." I'm simply asking that you don't say "having a Template class makes it very easy to nest templates within templates among other things."
 
user895378
1:32 PM
Because it doesn't get any easier than this:
 
user895378
12 mins ago, by rdlowrey
include 'templateFile.php';
... then in templateFile.php ...
include 'omgNestingTemplatesHere.php';
 
:D
 
@rdlowrey This all started from a nesting argument. At the end of the day the HTML comes out the exact same
 
user895378
Except one way is an overengineered mess of unnecessary userland code and one is built into the language precisely to avoid grinding your application performance to a halt.
 
@rdlowrey Dude calm down, this is just a discussion :P Be nice! It's E_FRIDAY
 
1:33 PM
@rdlowrey To a halt?
 
<?php require '/site/'.$_GET['file'].'.php'; ?> is the real way to go.
 
lol...
 
@Leri Haha
 
sigh
 
user895378
http://yoursite.com/file=../../../just-pwnd-your-server.php
 
1:34 PM
@LeviMorrison A by far, much clearer separation
 
@rdlowrey That may be true but your templates variable scope is to wide in my opinion
 
user895378
@David Define "too wide"
 
variable $x is in scope for all included templates
 
user895378
32 mins ago, by rdlowrey
function($vars) use ($templatePath) { extract $vars; include $templatePath; };
 
user895378
@David it's called "closure" for a reason.
 
1:36 PM
@rdlowrey I use views which render templates using a fluxcapacitator and it works wonders for me! WONDERS!
:D
 
You put that code where exactly?
 
user895378
What does that have to do with anything?
 
@rdlowrey OMG, you must be a hacker. :)
Off to university. Later.
 
stackoverflow.com/questions/22864353/… - why do so many PHP people still use 777 permissions without the slightest thought about what it means? :x
"Oh, this does not work because of permission denied - let's use 777!"
 
777 all the things
 
1:38 PM
@ThiefMaster if 777 doesn't work, nothing will work !
 
 
user895378
0777 should be pronounced "OH NO 777"
 
What if you have something where the user can select multiple rows from a table, maybe customers, and edit 5 at a time, you will be displaying the template to edit a customer 5 times, all with variables of the same name with different data for each customer. How do you deal with that then?
@rdlowrey
How do you deal with the scope of the variables. You can't have 5 $firstName variables
 
user895378
sigh
 
That's not a good answer
 
user895378
1:40 PM
You're not thinking logically about this at all.
 
user895378
$templater = new Templater('path/to/php/template.php');
$templater->bind('varname', 42);
 
user895378
^ that is the exact same thing I'm doing.
 
'meaningoflife', 42
 
user895378
And it has exactly zero effect on how easy/hard it is to nest templates.
 
Yes but if the application can edit 5 customers at a time. You retrieve the 5 customers, you need to include the HTML template 5 times for editing a customer and also bind each customers data to each template file. How would you do this your way? I would just create 5 template instances, set where the template file is and bind one customers data to each template. The scope is perfect and I can keep the names simple like $firstName, $lastName in each template file
 
user895378
1:43 PM
And somehow I can't create 5 closures?
 
user895378
The scope is perfect and I can keep the names simple.
 
Hi, can anyone provide a good tutorial reference on MVC architecture? Perhaps a functional tutorial?
 
@cclark413 Bad timing
@cclark413 Ask @rdlowrey
 
huehuehue
 
@cclark413 room-11.github.io/canonical.html under design there are some nice links
 
1:44 PM
lol
 
3 hours ago, by Second Rikudo
user image
Also that ^
 
user895378
@cclark413 When you say "functional tutorial" do you mean like "functional programming?" Or do you mean "something that you can copy/paste to see how it works?"
 
^ That's currently being discussed
 
@rdlowrey I mean one that I can walk through, and program myself. Not much for copying and pasting...
 
Good morning
 
1:46 PM
Room poll: Do we want a bot in this room? (i.e. Caprica Six)?
 
@HamZa Thanks!
 
No. I hate caprica six.
This room is not JavaScript, and not C++ (b*stards), and never will be!
 
user895378
@cclark413 I don't really know of one to recommend but I would suggest focusing on "separation of concerns" and not "MVC"
 
:D
@rdlowrey Not helpful. I used to think I had to cURL across controller | model in order to have that separation ;)
 
user895378
@Jimbo oh no!
 
1:48 PM
Oh they were the days :')
 
user895378
I didn't realize today was friday until just now
 
HTTP Request --> Controller, cURL request --> "UserModel" ---> Controller -> echo. ftw.
 
@Jimbo what's wrong with those rooms?
 
@rdlowrey Sounds good. I'll look into that!
 
user895378
@David I'm not trying to berate you, okay? It's not your fault I'm not fully explaining my points :)
 
1:49 PM
@AlmaDo Guys in C++ are noobs, JavaScript all bum each other. And PHP argues over mvc
 
@AlmaDo Try to participate in room 10
 
@Jimbo so what? I'm noob too
@HamZa I prefer ask first
 
@rdlowrey I get what your saying with the closures and the scope and all but I would really need a full example or at least a bit more code to really get where your coming from for the whole flow of the application
 
@SecondRikudo Yes a custom one which only does very narrow and specicifc things
I'm waiting for the node bot to be finished
 
@PeeHaa Define custom and specific things
 
1:50 PM
Stripped down version which only does a couple of useful thngs
I.e. get some canonical
or an evaller
 
hehe that would be awesome
 
evaller is kind of a must
 
user895378
@David I actually have a full-fledged example somewhere I can probably throw on github. And it's almost exactly what you're suggesting -- it just uses plain php files for the templates. Your approach is correct ... I was just trying to say that you can get all the same advantages offered by templating language DSLs with native PHP code.
 
Maybe we should make a PHP bot XD
 
Other than basic and/or useful stuff like that: god no
 
1:52 PM
Although I have no idea how it would integrate with chat properly.
 
Nope, no cross-room brawling :( Ah well, maybe some other time
 
SOCKETS!
:D
 
user895378
My SPDY sense is tingling. Did somebody say websockets???!!?!
2
 
Node would be just perfect for this @SecondRikudo
 
@rdlowrey Nah, just sockets :D
 
1:53 PM
@rdlowrey hahahahaha
 
@PeeHaa But can Node run a PHP evaller?
 
@rdlowrey Yeah. What about dealing with the response do you manage that in a closure like if you have to set the headers to do a force download of some content type
 
user895378
I always pronounce SPDY as "spidey" for some reason ... I'm sure it's problably supposed to be "speedy" but I don't care.
 
@SecondRikudo It can call my codepad using an api
It kinda was the reason I set it up
For a bot sometime in the future
 
@PeeHaa In that case, why don't we try and implement that with the existing bot code?
 
user895378
1:55 PM
@David Nah the templating stuff only deals with generating the textual response entity body. I treat headers as a different thing entirely.
 
Even if not complete, we can strip it down to the necessary stuff
 
@rdlowrey maybe because you watch and love spiderman?
 
user895378
@PeeHaa And it's bad-ass rockstar tech.
 
@SecondRikudo Feel free :) I already had a stripped down bot running at some point, but I wanted it to run on my server. At that time I understood from the JS people a serverside bot was in the makes so I abandonded the thing at the time
 
user895378
Everybody knows that apache applications are slow because they use blocking IO and have context switches.
 
1:57 PM
@PeeHaa Take it, run it on your server, connect a repo to it via GitHub or something, and use a hook to automatically push new code and restart the bot if needed.
We can probably make some elaborate branching model to have a "testing" bot and a "production" bot running at the same time.
 
Not sure what the status is of the serverside bot tbh
 
user895378
I'm a total speed junkie.
 
I prefer coke mys.....Oh.
 
@PeeHaa Isn't Caprica Six server-side?
 
user895378
But it's fast as hell.
 
1:59 PM
Ah, no it isn't.
 
user895378
You're a fanatic in the church of technology fashion.
 
Wtf is with mods rejecting all my flags lately? This is clearly not acceptable for an answer, it's a link only answer!
 
user895378
Non-blocking is the secret in the async sauce.
 
@SecondRikudo nope in runs in tab
 
@Jimbo Ask on meta.
@PeeHaa Yeah, I saw
Well, I don't know enough about chat to start a browser extension on it, let alone write a server-side app to connect to it :X
 
user895378
2:00 PM
I'm sad no one joined in with my rockstar tech quote fest :(
 
user895378
Did you just say "LISP?" I could have sworn you just said "LISP"
 
@rdlowrey When does non blocking IO fail? Becoming too slow?
If you had a ridiculous amount of input
 
user895378
@David What do you mean specifically by "fail?" Are you asking what the drawbacks of a non-blocking system are?
 
@Jimbo I got one declined "declined - flags should only be used to make moderators aware of content that requires their intervention". Maybe you should try "not an answer" or "low quality" ?
 
2:05 PM
@rdlowrey Basically yeah. What are its threshold/limits
 
@rdlowrey You understand there are people with an actual job unlike you right?
:)
 
user895378
@David It doesn't have any limits, really. That's the beauty of it. But the drawback is that it can result in code that's much more difficult to understand/maintain.
 
user895378
So, given that more/faster hardware is generally less costly than skilled labor it may or may not be a good idea to incur those costs.
 
user895378
@PeeHaa Oh, I just assume everyone who knows how to code automatically writes software that creates money for them ;)
 
@HamZa Yes, the first answer is wrong
 
2:08 PM
:D
 
@NikiC thanks for the confirmation
@Danack (facepalm)
 
user895378
@David However, if you can structure the non-blocking code in such a way that it feels like it's synchronous and executed in a straight line ... well then you have a really good solution.
 
@rdlowrey Cool it's an interesting topic I must look into further properly when I have the time
 
@NikiC I need a bit of your help. Could you check if my guess is correct ? (and also, what is that value)
 
hi guys
is anyone here? :)
 
2:17 PM
hi
 
@rdlowrey What if you have 50,000 people connected to a non blocking IO server and all clients push let's say an average of 10 bytes to the server at the same time. Would a performance decrease be noticeable?
 
user895378
@David A small one. For example, in my non-blocking http server I can service ~50,000 requests per second on a single machine when 1,000 clients are connected. If I bump that up to 20,000 simultaneous users the number of responses I can generate per second drops down to ~40,000.
 
user895378
But if you're servicing >= 50,000 requests per second I would hope you'd have more than one server machine on hand.
 
Is this written in PHP?
 
user895378
Yes.
 
2:20 PM
That sounds impressive figures
Wouldn't expect that
 
user895378
Well, it's easy to make "hello world" benchmarks look impressive ;)
 
Hello and good morning.
@SecondRikudo I vote no ^^
 
@LeviMorrison Why?
 
@rdlowrey How much RAM would be in use to hold the 1000 clients
 
@SecondRikudo I don't think it will add anything useful.
 
user895378
2:25 PM
A fair amount. Obviously PHP isn't as memory efficient as doing something like this in C. My testing has shown it costs about 10k of memory per client that's connected (in my server). But, if you're servicing 10,000 clients at a time on a single box then you ought to have 100MB of memory available.
 
@rdlowrey Git your fix lately?
 
user895378
But there are tons of usability improvements for having the code in an interpreted language too.
 
user895378
@LeviMorrison do you mean the reverse proxy?
 
s/Git/Get/
 
@SecondRikudo i think it would be useful but it would also cause a lot of spam so for me, its a no.. especially considering that Caprica is full of funny, corny responses that generally elicit a spam the command reaction from unfamiliar users
 
user895378
2:28 PM
@LeviMorrison Oh, I was just quoting the node rockstar tech video and goofing off ;)
 
hilarious example:
in HTML / CSS / WebDesign, 25 mins ago, by Caprica Six
@mikedidthis rep whore A person who is obsessed with their status on an internet forum so bribes/ does favours for members of that forum in an attempt to achieve higher rep points. I on the other hand am simply a whore and proud of it.
 
lol
 
@Jimbo speaking of repwhore, you should bribe @PeeHaa into giving you a 100 rep bounty
 
user895378
Ah, @Jimbo is within striking distance of 10k ...
 
@CarrieKendall Hey, I'm no repwhore! All natural me!
 
2:35 PM
oh, i wasn't implying you were ;]
UPVOTE HIMMMM
 
Yay :-)
@PeeHaa Give me 100 rep bounty or I'll tell everyone who you did to get it
 
4/4/2014 serial upvoting detected: -215
 
lol
 
11
Q: Design Patterns: How to create database object/connection only when needed?

PaniqueI've a simple application, say it has some classes and an "extra" one that handles database requests. Currently i'm creating the database object everytime the app is used, but in some cases there's no need for a database connection. I'm doing it like this (PHP btw): $db = new Database(); $fo...

 
2:40 PM
That's where I learned service locator is bad!
And wrote a load of shit about it!
 
user895378
@JoeWatkins yo
 
jo joe
 
so I might be creating something at work ... tell me if you'd be interested in this ... we have a massive codebase, 3m LOC, huge variey of talent, and however difficult statics are to debug, or maintain, they write static methods all the damn time, we started on a framework a couple of weeks ago, but I'm very oo, and it looks out of place next to the 3m lines we have ... so, in an effort to resolve differences, I have the following idea ... the facades pattern
uopz can implement that at the level of zend such that at runtime the framework creates a set of default facades which are actually classes from a concrete implementation and traits, then the programmer can do more of the same to assemble their business logic in controllers and whatever ... it's as debuggable as objects, there are objects, but it looks like and is as easy to write as statics ...
any thoughts ?
 
I have no idea what you're talking about, and I imagine them too.
 
SELECT * FROM queue WHERE locked != 0 ORDER BY machine, pid;
48 rows in set (0.02 sec)
@JoeWatkins I don't care for it
personally, I'd try to migrate the 3Mloc part by part. Not "for the sake of it", but when you need to modify a piece of code, you migrate it
the "facade" (static proxy) could be used during an individual migration, but it shouldn't be relied upon for the whole chunk IMHO, as since it's not tested you can't have confidence you didn't break anything
My $0.02 at least
 
2:56 PM
I don't mean they would create facades from the existing code ... we intend to migrate to a new framework/infrastructure, we don't intend to reuse the code as is, we do intend to rewrite it, porting it to the new framework ... which i wrote as pure OO, but nobody else is really comfortable with because of the current way code is being written ... so to allow the programmers to write as they normally do (static everything) but allow the whole framework and their code to be tested
 
I spend far too much time deciding whether to put "%%%%%" or var_dump('OMFGWTFBBQ'); to see if some code has executed.
 
What are the recommendations for line breaks in text files? Should I just do \n and ignore Notepad, or do \r\n to 'cover all bases'?
 
I would be very cautious about rewriting...
an in-place migration is going to be far more tenable and far more successful
 
@ŠimeVidas ignore notepad
...
 
@JoeWatkins then teach them. Don't half-ass it, slow velocity a little now for the longer term benfit
 
2:57 PM
No idea why you would ever care about it tbh
 
@ŠimeVidas What about PHP_EOL?
 
user895378
@JoeWatkins I saw your disagreement with Padraic on his HHVM blog article :) I totally agree with you and it's annoying to see the useless "PHP is dead" proclamation ... But Padraic is usually a sensible person and an okay guy in my experience. Try not to get too annoyed with that post :)
 
@ircmaxell it's a case of what is possible ... I don't feel able to teach them, but it's kind of my job to program my way around that isn't it ?
 

« first day (1266 days earlier)      last day (3700 days later) »