Asked  7 Months ago    Answers:  5   Viewed   33 times

I have a php application that is installed on several servers and all of our developers laptops. I need a fast and reliable way to get the server's hostname or some other unique and reliable system identifier. Here's what we have thought of so far:

<? $hostname = (!empty($_ENV["HOSTNAME"])) ? $_ENV["HOSTNAME"] : env('HOSTNAME'); ?>

<? $hostname = gethostbyaddr($_SERVER['SERVER_ADDR']); ?>

<? $hostname = exec('hostname'); ?>

What do you think?

 Answers

57

What about gethostname()?

Edit: This might not be an option I suppose, depending on your environment. It's new in PHP 5.3. php_uname('n') might work as an alternative.

Wednesday, March 31, 2021
 
Gil
answered 7 Months ago
Gil
86

You should point to your vendor/autoload.php at Settings | PHP | PHPUnit when using PHPUnit via Composer.

This blog post has all the details (with pictures) to successfully configure IDE for such scenario: http://confluence.jetbrains.com/display/PhpStorm/PHPUnit+Installation+via+Composer+in+PhpStorm

Related usability ticket: http://youtrack.jetbrains.com/issue/WI-18388

P.S. The WI-18388 ticket is already fixed in v8.0

Wednesday, March 31, 2021
 
ojrac
answered 7 Months ago
84
  • It should add p-tags instead of line break like.

Run it through something like the Textile interpreter, or Markdown, or any another humane markup language which suits your needs.

  • It should remove empty space like tripple spaces
  • It should remove double line breaks.
  • It should remove tabs.
  • It should remove line breaks and spaces before the content if any.
  • It should remove line breaks and spaces after the content if any.

Why bother? When HTML is rendered as a document, multiple white space characters are reduced to a single space, no? Most of your problems solve themselves.

Wednesday, March 31, 2021
 
WooDzu
answered 7 Months ago
79

On Mac OS X environment variables available in Terminal and for the normal applications can be different, check the related question for the solution how to make them similar.

Note that this solution will not work on Mountain Lion (10.8).

Saturday, May 29, 2021
 
Nate
answered 5 Months ago
52

Whenever I need the context in a form, I'm doing it via constructor injection.

in the action:

$this->form = new WhateverForm($whatever, array("context" => $this->getContext()));

in the form:

$this->getOption("context");
Sunday, August 15, 2021
 
keyBeatz
answered 2 Months ago
Only authorized users can answer the question. Please sign in first, or register a free account.
Not the answer you're looking for? Browse other questions tagged :