php-5.5

Right way to inject container service in Sonata Admin Bundle

一个人想着一个人 提交于 2019-12-11 12:41:42
问题 I'm trying to inject the service container in my Sonata Admin class in order to use it at configureFormFields method. This is what I have: config.yml (sonata services definition) services: tan.product.admin.product: class: Tan\ProductBundle\Admin\ProductAdmin tags: - { name: sonata.admin, manager_type: orm, group: Product, label: Product } arguments: [ null, Tan\ProductBundle\Entity\Product, @service_container] ProductAdmin.php class ProductAdmin extends Admin { /** @var \Symfony\Component

Symfony: 'zlib extension' missing

大城市里の小女人 提交于 2019-12-11 11:09:53
问题 I wanted to start with Symfony, but I even fail a the Quick Tour... $ php -r "readfile('http://symfony.com/installer');" > symfony.phar $ sudo mv symfony.phar /usr/local/bin/symfony $ chmod a+x /usr/local/bin/symfony $ symfony PHP Fatal error: Uncaught exception 'PharException' with message 'zlib extension is required for gz compressed .phar file "/usr/local/bin/symfony"' in /usr/local/bin/symfony:9 Stack trace: #0 /usr/local/bin/symfony(9): Phar::mapPhar('default.phar') #1 {main} thrown in

A controller that might violate Single Responsibility Principle?

两盒软妹~` 提交于 2019-12-11 03:47:56
问题 Referring to this comment, When a class has a very long list of arguments, it can be a "code smell" that your class is trying to do too much and possibly not following the single responsibility principle. If your class is trying to do too much, consider refactoring your code into a number of smaller classes that consume each other. What should I do about this controller class below - is it "trying to do too much"? class Controller { public $template; public $translation; public $auth; public

Ubuntu 14.04: Upgrade to php7 and uninstall php5?

邮差的信 提交于 2019-12-11 01:22:45
问题 I'm upgrading the php version to 7.0 in my docker image which is based on Ubuntu 14.04. I read some articles giving the commands to uninstall php5 while installing php7.0. Is this really necessary? What are the pros and cons? 回答1: add the new repository for PHP 7: apt-get install software-properties-common add-apt-repository ppa:ondrej/php remove PHP 5 from your system and install PHP 7 apt-get update && apt-get purge php5-fpm && apt-get --purge autoremove && apt-get install php7.0-fpm php7.0

PHP 5.5 Classname Resolution

半城伤御伤魂 提交于 2019-12-10 03:34:31
问题 PHP 5.5 has implemented as a new feature a new way to retrieve the classname through the syntax ::class : <?php namespace Testing; class Test{} echo Test::class; // Testing\Test; This works perfectly, alright? BUt what me and some other friends wanted to know is why this syntax also returns a classname when used alongside an undeclared class. E.g.: <?php echo UndeclaredClass::class; // UndeclaredClass In several other cases an error is raised, but not here. Anyone know, with concrete basis if

php not showing changes to files consistently

你离开我真会死。 提交于 2019-12-08 07:37:32
问题 I am making changes to php files and they are not showing -- sometimes. Sometimes they will show immediately. Sometimes I have to wait a few minutes. I've gone through and turned off all the cache that I could think to turn off. The problem is inconsistent and tough to duplicate consistently. 回答1: Answering my own question... I spent quite awhile doing trials to consistently reproduce the behavior. I had to let the server sit without refresh any page for a few minutes. Then if I change the

correct use of password_hash

a 夏天 提交于 2019-12-08 04:07:24
问题 I am trying to figure out the correct use of password_hash I have the following script below <?php $password = "test3"; $hashAndSalt = password_hash($password, PASSWORD_BCRYPT); echo $hashAndSalt; ?> as far as I know this is supposed to create a salt too? When ever I run the script the beginning of the hash starts with "$2y$10$" the remainder always changes on each run. $2y$10$.YHHLeFYcQoE6c//vl587uIFTOljmpmuDnSA0w0dxo1Rrpvi5zM9m <- run one $2y$10

Check for commonly mis-recognized characters in a string against a list of known strings

这一生的挚爱 提交于 2019-12-07 09:44:28
问题 Background I have a list of codes in my (MySQL) database that consist of six (6) characters. They consist of numbers and letters chosen at random. They are considered case-insensitive, however they are stored as uppercase in the database. They may consist of the number 0 but never the letter O . I use these code as one-off authentication of users. The Problem The codes have been handwritten on cards and unfortunately some letters and numbers may look alike to some individuals. This is why I

What does `session.entropy_length` in `PHP.ini` do?

陌路散爱 提交于 2019-12-07 00:43:24
问题 In the session section of PHP.ini there is a directive called session.entropy_length . I'm aware that it's used to make the generation of the session id more random. How does it do that? What is the maximum length? What if it's exceeding the bits of the hash in use? 回答1: session.entropy_length specifies the number of bytes which will be read from the file specified above. Defaults to 0 (disabled). PHP Manual The "file mentioned above" is session.entropy_file 'entropy' for sessions is related

correct use of password_hash

安稳与你 提交于 2019-12-06 16:06:47
I am trying to figure out the correct use of password_hash I have the following script below <?php $password = "test3"; $hashAndSalt = password_hash($password, PASSWORD_BCRYPT); echo $hashAndSalt; ?> as far as I know this is supposed to create a salt too? When ever I run the script the beginning of the hash starts with "$2y$10$" the remainder always changes on each run. $2y$10$.YHHLeFYcQoE6c//vl587uIFTOljmpmuDnSA0w0dxo1Rrpvi5zM9m <- run one $2y$10$b6n3chpTQk1X7c0OdPp0ceZmw3GvZFsLx9FHq9RnYaJgbld915oYG <- run two $2y$10$AGffB7R1rTko8UmS1m6wT.ybG78.CkwrxqoRteNMeRPXexpSJW5iO <- run three Is it