« first day (261 days earlier)      last day (4909 days later) » 
01:00 - 13:0013:00 - 23:00

13:00
hey
how to create a node with simplexml with name atom:link?
$self = $feed->channel->addChild('atom:link'); <---- this adds <link ... /> element :-S
@Raynos , would you really do something like this in javascript ?
@zerkms Use third param?
function foobar( config ){
      var type = config;
      delete config;
      type = Object.create( 'something' , { 'will_be_private' : type } ) ;
}
@Robik: how? ;-)
@zerkms the docs should help -- php.net/simplexmlelement.addchild
13:05
posted on July 04, 2011 by Danne Lundqvist

A while ago I saw a lot of people writing about their PHP development environment and tools. I didn’t get around to it at the time but yesterday I found me some time to write down my experiences of moving from Linux to MacOS X as primary OS for PHP  and web development Me and my partner in Dotvoid, a small web development and integration company, have used linux as a client OS for more than a

.. and in JS it actually even looks easier to understand
@zerkms $self = $feed->channel->addChild('link', $value, 'atom');
oh
nope
that is what I tried with no luck
BUT
$self = $feed->channel->addChild('atom:link', null, 'atom');
this works
the difference is in "atom" duplicated in the name and in namespace parameter
@zerkms take out atom: from the element name, and put the URI (not the prefix) in the third parameter
@salathe: :-S
am I looking like a dummy?
$self = $feed->channel->addChild('link', null, 'atom'); produces <link xmlns="atom"
$self = $feed->channel->addChild('atom:link', null, 'atom'); produces <atom:link xmlns:atom="atom"
13:10
@teresko depends what you mean. Deleting local variables is a) not allowed and b silly
@zerkms not at all
well, it generates not necessary xmlns:atom="atom"
/me is a sad panda
return str_replace(' xmlns:atom="atom"', '', $feed->asXML()); --- such a weird code, but validator is happy. So am I
@Raynos , well , in Yii code , it takes the function parameter , assigns it to different variable , removes the original , and then the backup value replaces with object , to which it passes that backup value in constructor
why are you specifying atom as the namespace URI?
@salathe: that is what w3c rss validator wants
13:14
it's almost as if someone by-design is trying to obfuscate the logic
some of my clients noticing me about some rss readers issue - so I'm trying to fix left bugs to make it completely valid
@zerkms if it's what it wants, why str_replace() it away?
Don't know what dirty code lies behind Kohana's Inflector class, but I like it :)
@salathe: it doesn't want ' xmlns="atom"' part
this part makes rss feed invalid
xmlns is added by simplexml, automatically. I didn't ask it to do that ;-)
@zerkms what about providing valid xmlns? :)
13:16
@KamilTomšík: what about not adding attributes I didn't ask?
;-)
@zerkms it's only added because you're doing it wrong
:-S
again then
how to add atom:link item? ;-)
@zerkms I guess you can force simplexml to not add namespaces - there is option for that, but valid atom should contain this anyway: xmlns="http://www.w3.org/2005/Atom"
use the namespace URI (http://www.w3.org/2005/Atom) instead of atom for the third parameter, and take away atom: from the first
<rss xmlns:atom="http://www.w3.org/2005/Atom" version="2.0">
I already have it
and everything is fine with it
13:18
no it's not
What I'm talking about is atom:link with self-reference
uhm
you want <rss xmlns="http://www.w3.org/2005/Atom" version="2.0">
nope
@salathe seriously, who puts those into the the Manual?
13:19
according to validator I want what I copied
your version does not say anything about rss, it only defines new namespaces INSIDE of it
@Gordon no-one yet, thankfully ;)
@teresko ... Why would they do that?
yes, I'm a dummy
@salathe i'll update the manual again once i got my talk done. should have plenty material then
13:21
@zerkms you want either <atom:feed xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"> - and everything has to be prefixed with atom:xxx or <rss xmlns="http://www.w3.org/2005/Atom" version="2.0"> and then you don't prefix anything...
@KamilTomšík No he doesn't
he wants an RSS feed, with some Atom stuff inside
@salathe ah, sorry then...
I told him how to do what he wants, multiple times... then showed him... I can't do any more!
he's gone suspiciously quiet though, I suspect it's working now :)
13:26
@salathe: I've agreed that I'm dummy
and thank you :-)
you're welcome, did you get it working (without silly str_replace()) ?
ыгку
sure
$self = $feed->channel->addChild('link', null, 'http://www.w3.org/2005/Atom');
the null is weird, but that will work :)
it is better than "Hi!" ;-)
I wouldn't say so!
well that was hard work, I need a break... back to the day job
13:42
1
A: Almost graduate, how to prepare myself for the "real world"?

job Take a look at open source projects (wordpress, joomla, drupal), you can download the code and take a look on how its implemented, that kind of projects are always updating, mainly because of security concerns. It will let you know good practices And the latest practices. As you mentioned doi...

would you expect registerRequestByName(HttpRequest $request, $name) or rather registerRequestByName($name, HttpRequest $request)
This guy claims reading the source code of "Drupal, joomla, wordpress" is a good thing
Is their source good or a mess?
@Raynos absolute total mess and software metrics prove that. there is methods in wordpress with cylcomatic complexity in the thousands
@Raynos unfortunately, when talking about the 'real world', this is likely what to expect, so its not totally wrong :)
I have a problem with regular expression. I am trying to match quotations, it works okay with strings like "a" or "b" + "c" but it doesn't with that: "a \" b " (this should be matched as one). My Pattern: \"[^\"]*\". But i have no idea how to exclude \"
would ([^\\]*|\[^"]*) work?
13:54
Unfortunaly no, it doesn't work with "a \" c" :(
@salathe Thanks.
Nice flame about PHP in C++ room :P
in Lounge<C++>, 49 secs ago, by Cat Plus Plus
PHP sucks.
^^
14:18
that's true, because c# only rocks
Then what are you doing here? :P
lets all go there and flag it :D
PHP sucks.
33
@salathe But who cares?
@salathe its something different when we say it
14:20
@Gordon because we really mean it? :)
Oh, oh! New arguments:
in Lounge<C++>, 2 mins ago, by Cat Plus Plus
Idiotic type system, inconsistent grammar, pile of shit instead of standard library, weird and utterly stupid architecture of the official implementation (php.ini, restart-on-every-request and crap like that), to name few things from the top of my head.
@salathe because we are not flaming
@Gordon I guess
@Robik if by standard library the OP means STL, then we have SPL.. and the "idiotic type systems" remark hints at OP not liking dynamic typing which means he's a dinosaur. and complaining about "restart on every requests" means OP never had to write something that scales
Time to revange on C++ >:D
14:22
@Robik nah, dont feed language flamer trolls
@Robik its pointless.. you wont convince that guy anyway
Yeah, you're right
but that guy is partially true anyway
And partially wrong
But it's his opinion
it's just jealousy. He wishes he could write programmes as quickly as a PHP dev can pull together a website
14:27
@zerkms PHP scales from a simple web form to the largest social network in the world. if it can do that, any complaints about it are moot. it sure aint the prettiest language out there, but its the most adopted scripting language and it sure is capable of getting things done.
Good Morning
Afternoon @ircmaxell
How's it going?
Deja-vu?
14:38
19 mins ago, by salathe
PHP sucks.
Pinned
in Lounge<C++>, 22 mins ago, by Cat Plus Plus
PHP sucks.
Pinned
Weird
@Robik ... PHP does suck.
So does C++
so does javascript
Well, it depends on your definition of suck
Well, suck like vaccum does
14:40
They are all horrible non-pure academic languages
Use Scheme
C# and Java also suck
do not google "suck like a vacuum" at work
I can kind of live with assembly. Assembly is pretty pure, so I guess it doesnt suck
that was unexpected
@Raynos Why everything sucks in your world?
@Robik because it does :\
there all mediocre languages
14:42
assembly is just a wordier version of C. How do you mean pure?
again, it depends upon your definition of sucks
any idea on how to improve readability and abstraction of this snippet?
My definition of sucks is simple.
$webService = new WebService;
$webService->registerRequest('fetchContent', function() {
    return file_get_contents(
    	'http://www.example.com',
        false,
        stream_context_create(
            array(),
            array('notification' => function() {
                print_r(func_get_args());
            })
        )
    );
});
echo $webService->request('fetchContent');
> The language has at least one bad part
15:06
eih
@Raynos lisp suck too :-D
and so JS does
@Gordon simple file_get_contents isn't enough?
@KamilTomšík no
aim is to create a webservice by configuration
fiddling with the conversion to closure right now
$webService = new WebService;
$webService->registerRequests(
    array(
    	'fetchContent' => array(
			'url' => 'http://www.example.com',
			'context' => array(),
			'notifications' => array()
        )
    )
);
$webService->request('fetchContent');
then registerRequest will map that data into a closure and at runtime i can then simply call request('foo')
15:25
@KamilTomšík Blasphemy
15:37
@Gordon
in st, I would:

webService mapRequest: [ :req |
  req
	name: 'fetchContent';
	url: 'http://example.com';
	context: #{};
	notifications: #{}
]

in php I'd stick with arrays or with builder

$webService->mapRequest(function($reqBuilder){
  $reqBuilder
    ->name("fetchContent")
    ->url("http://example.com")
    ->context(array())
    ->notifications(array())
})
@Gordon was it helpful?
not that much
have to reconsider the approach.. making a static get or post works but im not sure on how to allow for passing arguments to a request yet or if i want to allow that all
also, in your php example i dont see how it would work at all
@Gordon webService has requestBuilder, it will "borrow" it to passed lambda - for configuring - then it will just obtain instance from that builder.

st example is IMHO better, because those "name: xxx" are actually just setters on already created request
15:52
how do you invoke a request?
$webService->request() - just like you do...
then I dont understand mapRequest
when is that lambda called?
i actually like that builder pattern better than plain arrays for its API
1. webService->mapRequest is called (with lambda acting as configuration)
2. mapRequest() creates/reuses builder for requests and pass it to lambda
3. lambda configures request
4. lambda finished, mapRequest obtains configured request instance from builder
5. stores that request
6. finito!
:-)
so i would have $webservice = new Webserver(new RequestBuilder)
16:01
nice
how would i use this with parametrized requests?
this is the main issue actually
well, I'm not sure what is parametrized request at the first time, could you provide example of what you need? :)
$webService->request('SalarayAfterTax', array('salaray' => '100000'))
usually i would write a stupid hard coded Gateway for stuff like this.. this one would have a method getSalaryAfterTax and then all required calls and all would be fine. But I figured I could do this in a more dynamic fashion
@Gordon why not leverage true RPC?
@Gordon because it looks like you want just call method with params and get result...
@Gordon why don't you know everything? :(
...method on remote object - service
16:09
@Raynos because $deity forgot to give me that gift ;)
$request = xmlrpc_encode_request("method", array(1, 2, 3));
$context = stream_context_create(array('http' => array(
    'method' => "POST",
    'header' => "Content-Type: text/xml",
    'content' => $request
)));
$file = file_get_contents("http://www.example.com/xmlrpc", false, $context);
$response = xmlrpc_decode($file);
if ($response && xmlrpc_is_fault($response)) {
    trigger_error("xmlrpc: $response[faultString] ($response[faultCode])");
} else {
    print_r($response);
}
@kamil basically, the middle part is what i am already doing
i just dont want the other stuff. what if i want to talk to a REST api?
or get JSON instead of XML
besides, there isnt any endpoints on that particular webservice
at least not in the rpc sense
well... builder is great way for requiring only few things - for example url can be partially inferred from name, context, notifications are obviously not required, so...
$webService->mapRequest(function($reqBuilder){
  $reqBuilder
    ->name("fetchContent")
})
$webService->request("foo", array(params...));
should be enough... you can make POST default and add another method to builder - for being able to override this.
something along the lines of this.. not sure on how to override though
$webService->mapRequest(function($reqBuilder){
  $reqBuilder
    ->name("fetchContent")
    ->method("GET") //optional
})
or where's the problem? :)
16:24
specifying a method isnt the problem. that would go into context anyways
the problem is separating those parts of request that are known in the beginning and those that are not, e.g. those that are user supplied
honestly, I don't follow... sorry :)
its creation vs using
16:40
I still don't see it - you create webservice, you configure it, then you'll use it, what's the problem?
passing runtime data
its $webservice->getAlbum(123) or $webservice->findWhereArtistLike('Hendrix')
i could use uri templates for get
17:20
hello guys
17:56
guy anyone know how to send post request for a local file using Curl ? the url must be "test.php" not "http://locahot/test.php"
@Fouad you can try with file:///test.php but i doubt this will work.
@Gordon i will try this one now
@Gordon not working :( its only working within the HTTP request don't know why :(
18:12
/me finally understood why it's so empty over here today: Independence Day in America ^^
@Fouad well, likely because cURL is not used to access local files.. your file system is not serving them the same way as server would
@Gordon is there any other method i can send this post request i can use the HTTP request but its security risk
@Fouad Maybe you tell us what you're trying to achieve. We could maybe find an alternative solution ;)
@nikic ok im building script which will use huge loop useing some post request so my best solution was to send those post request using curl to the script and let the script loop and work behind the scene so when user start to work within my script he will not feel slow or load when posting the data
ah, okay, so you basically have two php processes, one communicating with the frontend and the other doing the hard work?
18:19
yep
i built a class for curl issues but its working only when use the full url not working with the local files
Can't use use something like pcntl to communicate with the other process
lemme check if its installed or not
"Currently, this module will not function on non-Unix platforms" im on windows :)
Hm, in that case I don't really know how to manage multiple processes, sorry
try Gearman
that will allow you to offload the heavy load to a worker process
@Gordon i was thinking about it but the problem that the client don't have root access so he can install it
18:28
any of these are out of question then? stackoverflow.com/questions/2444157/…
if you are on PHP5.3 you can try kore-nordmann.de/blog/0098_native_job_queue.html then
otherwise, you will really have to look into pcntl.. but that's ugly
@Gordon kore's implementation uses pcntl too ;)
oh. sorry.. you said "cant use".. didnt see
i was thinking in using fsockopen then sending headers using fputs
no luck i think i will use the http post and trying to make sure the data came from my script its risk but its the only method i think
 
1 hour later…
19:59
posted on July 04, 2011

In a new post Gonzalo Ayuso talks about some of the new features in the recently released PHP 5.4 alpha, including some code examples. We already have the php5.4 alpha ready for testing. This new release has a few features that I really like. The lack of those features gave me problems in the past. Because of that, I'm very excited waiting for the new stable release of PHP 5.4. There's se

20:38
posted on July 04, 2011

Bradley Holt has a new post to his blog today talking about the experience he's had with testing the PHP 5.4 alpha1 release, just posted from the PHP development group. Rasmus Lerdorf today posted instructions for testing the upcoming PHP 5.4 release. Running the PHP tests and submitting the associated report will help the PHP team get PHP 5.4 ready faster as it gives them reports of failed

20:55
What is the best way to save a username/password combo for a database? I want to make an installer, so i can't put it out of the webroot. can I just make it untouchable with .htaccess?
21:15
@salathe - Is it me or there's no getDocComment() for ReflectionMethod?
@salathe Speaking of which, how am I supposed to use reflection classes when there's no documentation?!
/* Inherited methods */
final private void ReflectionFunctionAbstract::__clone ( void )
public string ReflectionFunctionAbstract::getDocComment ( void )
and why on earth would anyone need docs for the Reflection API when almost all of the methods are getters with very verbose and speaking names? And what docs are missing anyways? It's not like there was nothing at all. And why dont you contribute what you feel is missing at edit.php.net?
Even more importantly, how is it stuff that should have been generated isn't there?
in particular?
You know @Gordon, I'm lucky. I'm really lucky I don't have to mess with PHP's internals.
The snippet I pasted up there is straight from de.php.net/manual/en/class.reflectionmethod.php
21:21
The little time I did caused more brain-damage than BASIC's GOTOs
Anyhow, so it seems the function index doesn't list inherited methods?
Am I right?
what function index?
It's all there in the Class Synopsis
i'm a beginner in oop and php, it took me all of about 30 minutes to figure reflection out. i agree with Gordon, ReflectionMethod::getDocComment() is pretty self-explanatory
@ChristianSciberras there.. yeah.. there its not listed. but its on the actual page for ReflectionMethod. Inherited methods are never listed there. cf de2.php.net/manual/en/book.dom.php
@CharlesSprayberry - Sure is. Doesn't explain the fat warning; "This function is currently not documented; only its argument list is available."
I mean, how hard is it to @link it to its parent, if it the same exact copy?
21:29
if you think it needs improvement go to edit.php.net and improve it
I agree. I'd rather see some more documentation there. But, when I find docs missing for the stuff I use I try to figure it out on my own and once I do I submit my docs to the team. If enough people do that they can remove that warning.
Well, I didn't know about that even. Thought the docs were generated.
it is generated
its both
iirc
Well, if I get some time, some day, I'll try do people's work. sigh
either way, reflection in particular is one of those occasional pieces of code that's pretty much self-documenting. the code explains itself
at least the client code that i use...i can't speak for the internals :P
21:33
@ChristianSciberras php is open source. it's a community effort. dont expect people to write that for you.
@Gordon - I expect that if someone wants to do a job right, he writes both the code and the documentation.
Open source, community or not.
well, come to IPC then. There will be lots of core developers and you can tell them straigh in the face that they are not doing it right. And that they should get of their lazy a**es and write docs for you.
@Gordon :-D
@Gordon - I'd gladly help, but I still think that one that writes the code is more suited to writing the docs. For one thing, he could cover "exceptions" others can't.
Plus, it's good practice. Just as some people fall off their chair and shriek out when anyone mentions "static".
Tek
Tek
Does anyone know of the fancy HTML/table PHP markup when it throws an error? I just reinstalled it and now debugging errors are just plain text. =(
@Tek Table/fancy? It just throws bolded text, that's all.
Tek
Tek
21:46
@ChristianSciberras itwriting.com/images/php-error.gif It used to throw errors like this
But now it's just bolded/plain text
I forgot to reconfigure my xdebug extension when reinstalling php
=)
22:22
@PHP WHY YOU TROLL C++
Tak
Tak
Tek and Tak eh
Jez
Jez
Hi everyone, anyone here use Debian?
Tak
Tak
@Jez Sure, but I'm rather ignorant of it's inner workings
Jez
Jez
@Tak ah, would you like to follow my Area51 Debian proposal?
could be useful...
1
Debian

Proposed Q&A site for debian users and developers.

Currently in definition.

Tak
Tak
Oh I thought you had a Debian-based PHP question :P
Jez
Jez
22:34
:-)
nah
got a bunch of debian questions though
01:00 - 13:0013:00 - 23:00

« first day (261 days earlier)      last day (4909 days later) »