Questions tagged [php-fig]

PHP Framework Interoperability Group

PHP-FIG, short for PHP Framework Interoperability Group, is responsible for all the PSR Guidelines. http://www.php-fig.org/

11 questions
4
votes
2 answers

PSR-1: 2.3. Side Effects: variable inside config file

PSR-1 includes recommendation 2.3. Side Effects: A file SHOULD declare new symbols (classes, functions, constants, etc.) and cause no other side effects, or it SHOULD execute logic with side effects, but SHOULD NOT do both. Consider this example…
Fabien Snauwaert
  • 4,995
  • 5
  • 52
  • 70
4
votes
3 answers

Dependency injection in PHP (slim, php-di)

I have a Slim Php (slim4) application to which I added Monolog for logging purposes. I'm adding the logger to the application like this: $containerBuilder->addDefinitions([ LoggerInterface::class => function (ContainerInterface $c) { $logger…
S. Roose
  • 1,398
  • 1
  • 12
  • 27
3
votes
2 answers

How to call function (controller action) in PSR-15 middleware stack

I have read PSR-15 from PHP-FIG (HTTP Server Request Handler) and wondering when an action is called (Controller action or Closure). When processing through all middlewares the action should be called after passing all middlewares. After the action…
bhdzllr
  • 123
  • 2
  • 8
3
votes
3 answers

What will line ending cause when programming?

There is a thing make me puzzled in 2.2 of PSR-2 document. All I know is that different os use different line ending as default : windows:CRLF unix:LF mac:CR I want to know why should "All PHP files MUST use the Unix LF(linefeed) line ending"…
chenxinlong
  • 1,677
  • 2
  • 15
  • 30
2
votes
1 answer

Is using alternative PHP syntax for control structures PSR compliant? (when mixed with HTML)

I have looked through the PHP-Fig website for any PSR related to alternative PHP syntax for control structures but failed to find anything about it. The alternative syntax is this for example:

block…

Theo
  • 2,262
  • 3
  • 23
  • 49
2
votes
2 answers

How to parse / validate / handle http headers in PHP

Currently i am building my own php framework and i am now creating an implementation of the PHP-FIG PSR-7 MessageInterface. In specific the withHeader method. It states that the method could trow an exeption: \InvalidArgumentException for invalid…
ITGuy1990
  • 93
  • 1
  • 9
1
vote
1 answer

Plural or singular naming standards for sub-properties

A fair amount is written regarding class naming convention but not as much for properties and variables. The typical rule of thumb seems to be do what sounds right. The variable name for a single item should be singular such as $user. Arrays are…
user1032531
  • 24,767
  • 68
  • 217
  • 387
1
vote
0 answers

Should I implement both RequestInterface and ServerRequestInterface

I am currently writing an implementation of the HTTP Message Interface Recommendation (PSR-7) for my personal PHP framework. I've written classes for each interface in the recommendation. But now I realize that I do not need an abstraction for…
Youmy001
  • 515
  • 3
  • 11
0
votes
1 answer

Best practice for TYPO3 Backend and PSR-15

I have a question regarding TYPO3 9 (and future versions) and PSR-15. AFAIK most of the backend modules implement a handleRequest method for backend module controllers that have the same signature as PSR-15's RequestHandlerInterface. Is it intended…
CDRO
  • 130
  • 1
  • 9
0
votes
2 answers

Getting Error in PHP Autoload

I am using PSR-0 for auto loading, I know that I need to use PSR-4 which I will do it latter part. Even if PSR-4, answers are welcome. I am having the following directory structure for which the auto loading works fine. + www/entity |__…
Channaveer Hakari
  • 2,769
  • 3
  • 34
  • 45
0
votes
1 answer

How to circumvent PSR-2?

When Laravel 5.1 is upon us, PSR-2 will be enforced. I'm a big fan of PHP-FIG, unfortunately for me I got really used to and comfortable with control structures in a new line. Consider this current piece of code, already adhering to…
user2094178
  • 9,204
  • 10
  • 41
  • 70