Jeśli jesteś właścicielem tej strony, możesz wyłączyć reklamę poniżej zmieniając pakiet na PRO lub VIP w panelu naszego hostingu już od 4zł!

Archive for Grudzień, 2016

TutsPlus.com: Programming With Yii2: Helpers

TutsPlus.com: Programming With Yii2: Helpers

The TutsPlus.com site has continued their "Programming with Yii2" tutorial series with a new post introducing you to helper functions that come bundled with the framework. It also shows you how to create your own custom helper function, making it easier to perform common functions custom to your application.

In the Programming With Yii2 series, I’m guiding readers in use of the Yii2 Framework for PHP. In this tutorial, I’ll provide a brief overview of helpers. In Yii, helpers are modules which group commonly useful libraries for string, file, image, URL and HTML management amongst other things, and they are easy to extend.

I’ll also share an example of creating a helper within Meeting Planner, the focus of our Envato Tuts+ startup series.

The tutorial then introduces you to (and links you to) the common helpers the framework comes bundled with including the ArrayHelper, FileHelper and Markdown helpers. The tutorial then covers two in a bit more detail, the ArrayHelper and HtmlPurifier helper, including some code examples for each. Finally it shows the creation of a custom helper with several custom functions and their use in a template.

Source: http://www.phpdeveloper.org/news/24743

<!–
var d = new Date();
r = escape(d.getTime()*Math.random());
document.writeln('’);
//–>

Codeception Blog: Writing Better Tests: Expectation vs Implementation

Codeception Blog: Writing Better Tests: Expectation vs Implementation

The Codeception blog has recent post they’ve written up talking about writing better tests for your application and the difference between expectation and implementation as it relates back to meaningful tests.

What makes a meaningful test? This question should always be asked. No matter we write your tests first or tests after, they may stay in a project for years and it is pretty important them to test the things that really matters. Badly written tests can slow us down by constantly failing on each implementation change, and such tests can be written no matter you follow TDD or not. The idea of a test is to ensure that software works and not to freeze it at specific point.

Such situation happens when a test is bound to implementation details. [...] But how to understand what is stable and what is not? We need to use interfaces. Not that one which is written as interface keyword in PHP but a general term: User Interface, API. And that’s what makes unit testing and browser testing similar: we always need to rely on public interfaces for a test.

They give an example of a test that’s "bound to implementation details" from the Magento codebase that relies on a specific function implementation (the "makdir" method). This function is a part of the Symfony functionality, not Magento, and what might happen if things change in your application. They note that the main difference is testing for the result versus testing for the behavior of the functionality. The tutorial wraps up by suggesting that the only testing that should be done is on public, well-defined interfaces that are not as subject to change and not copying logic into tests.

Source: http://www.phpdeveloper.org/news/24742

<!–
var d = new Date();
r = escape(d.getTime()*Math.random());
document.writeln('’);
//–>

Codeception Blog: Writing Better Tests: Expectation vs Implementation

Codeception Blog: Writing Better Tests: Expectation vs Implementation

The Codeception blog has recent post they’ve written up talking about writing better tests for your application and the difference between expectation and implementation as it relates back to meaningful tests.

What makes a meaningful test? This question should always be asked. No matter we write your tests first or tests after, they may stay in a project for years and it is pretty important them to test the things that really matters. Badly written tests can slow us down by constantly failing on each implementation change, and such tests can be written no matter you follow TDD or not. The idea of a test is to ensure that software works and not to freeze it at specific point.

Such situation happens when a test is bound to implementation details. [...] But how to understand what is stable and what is not? We need to use interfaces. Not that one which is written as interface keyword in PHP but a general term: User Interface, API. And that’s what makes unit testing and browser testing similar: we always need to rely on public interfaces for a test.

They give an example of a test that’s "bound to implementation details" from the Magento codebase that relies on a specific function implementation (the "makdir" method). This function is a part of the Symfony functionality, not Magento, and what might happen if things change in your application. They note that the main difference is testing for the result versus testing for the behavior of the functionality. The tutorial wraps up by suggesting that the only testing that should be done is on public, well-defined interfaces that are not as subject to change and not copying logic into tests.

Source: http://www.phpdeveloper.org/news/24742

<!–
var d = new Date();
r = escape(d.getTime()*Math.random());
document.writeln('’);
//–>

Voices of the ElePHPant: Interview with Beau Simensen (#2)

Voices of the ElePHPant: Interview with Beau Simensen (#2)

The Voices of the ElePHPant podcast has posted their latest episode, another in their series of interviews with members of the PHP community. In this latest show host Cal Evans talks with Beau Simensen of SensioLabs.

Cal and Beau talk about Beau’s work at SensioLabs and some of his recent interactions with the community. They also talk about the difference between PHP conferences and Symfony conferences and why they vary so widely in audience size. They also talk about Symfony Flex (introduced in a recent keynote) and what it provides to make it simpler to bootstrap a new application. They also talk about SensioCloud, a new hosting platform geared for developers with a mostly command-line interface.

You can catch this latest episode either using the in-page audio or video player or you can download the mp3 of the show directly. If you enjoy the show, be sure to subscribe to their feed and follow them on Twitter for updates as new episodes are released.

Source: http://www.phpdeveloper.org/news/24741

<!–
var d = new Date();
r = escape(d.getTime()*Math.random());
document.writeln('’);
//–>

Voices of the ElePHPant: Interview with Beau Simensen (#2)

Voices of the ElePHPant: Interview with Beau Simensen (#2)

The Voices of the ElePHPant podcast has posted their latest episode, another in their series of interviews with members of the PHP community. In this latest show host Cal Evans talks with Beau Simensen of SensioLabs.

Cal and Beau talk about Beau’s work at SensioLabs and some of his recent interactions with the community. They also talk about the difference between PHP conferences and Symfony conferences and why they vary so widely in audience size. They also talk about Symfony Flex (introduced in a recent keynote) and what it provides to make it simpler to bootstrap a new application. They also talk about SensioCloud, a new hosting platform geared for developers with a mostly command-line interface.

You can catch this latest episode either using the in-page audio or video player or you can download the mp3 of the show directly. If you enjoy the show, be sure to subscribe to their feed and follow them on Twitter for updates as new episodes are released.

Source: http://www.phpdeveloper.org/news/24741

<!–
var d = new Date();
r = escape(d.getTime()*Math.random());
document.writeln('’);
//–>

Community News: Latest PECL Releases (12.27.2016)

Community News: Latest PECL Releases (12.27.2016)

Latest PECL Releases:

  • couchbase 2.2.4
    This is the GA release of the 2.2.4 SDK. It is a maitenance release
    with several fixes:

    Changes:

    • PCBC-401: embed PHP classes using pcs. This fixes performance issue,
      where the extension spending time during each request to evaluate
      and load Couchbase classes written in PHP. The pecl/pcs extension
      have to be installed and loaded before loading couchbase SDK.
    • PCBC-439: reset MCISCOMPRESSED before type detection.
      This fixes decoding compressed values.
    • PCBC-438: install callback for replica read command.
      This fixes getFromReplica() returning NULL.
    • Documentation updates and bug fixes
  • Druid 0.6.0
    - Fix #2 missing extension dependencies
    - Fix #3 Support PHP 7.
    - Support config curl_dns_cache_timeout,curl_connect_timeout,curl_timeout.

  • swoole 1.9.3
    - Added extension function args info
    - Added package_length_func option
    - Added http_client download method
    - Fixed issue#965
    - Fixed issue#966
    - Fixed issue#967

  • Druid 0.3.0
    - First version for pecl.net
    - Support PHP 5.*.

  • pdflib 4.1.0
    - add support for PDFlib 9.1
  • igbinary 2.0.1
    - Compatible with PHP 5.2 – 7.0
    - Fixes bug in session decoder not calling __wakeup() in php 7.0+
    - (Enhancement) Reuses identical strings when unserializing objects and arrays in php 7.0+

Source: http://www.phpdeveloper.org/news/24740

<!–
var d = new Date();
r = escape(d.getTime()*Math.random());
document.writeln('’);
//–>

Community News: Latest PECL Releases (12.27.2016)

Community News: Latest PECL Releases (12.27.2016)

Latest PECL Releases:

  • couchbase 2.2.4
    This is the GA release of the 2.2.4 SDK. It is a maitenance release
    with several fixes:

    Changes:

    • PCBC-401: embed PHP classes using pcs. This fixes performance issue,
      where the extension spending time during each request to evaluate
      and load Couchbase classes written in PHP. The pecl/pcs extension
      have to be installed and loaded before loading couchbase SDK.
    • PCBC-439: reset MCISCOMPRESSED before type detection.
      This fixes decoding compressed values.
    • PCBC-438: install callback for replica read command.
      This fixes getFromReplica() returning NULL.
    • Documentation updates and bug fixes
  • Druid 0.6.0
    - Fix #2 missing extension dependencies
    - Fix #3 Support PHP 7.
    - Support config curl_dns_cache_timeout,curl_connect_timeout,curl_timeout.

  • swoole 1.9.3
    - Added extension function args info
    - Added package_length_func option
    - Added http_client download method
    - Fixed issue#965
    - Fixed issue#966
    - Fixed issue#967

  • Druid 0.3.0
    - First version for pecl.net
    - Support PHP 5.*.

  • pdflib 4.1.0
    - add support for PDFlib 9.1
  • igbinary 2.0.1
    - Compatible with PHP 5.2 – 7.0
    - Fixes bug in session decoder not calling __wakeup() in php 7.0+
    - (Enhancement) Reuses identical strings when unserializing objects and arrays in php 7.0+

Source: http://www.phpdeveloper.org/news/24740

<!–
var d = new Date();
r = escape(d.getTime()*Math.random());
document.writeln('’);
//–>

Community News: Latest PECL Releases (12.27.2016)

Community News: Latest PECL Releases (12.27.2016)

Latest PECL Releases:

  • couchbase 2.2.4
    This is the GA release of the 2.2.4 SDK. It is a maitenance release
    with several fixes:

    Changes:

    • PCBC-401: embed PHP classes using pcs. This fixes performance issue,
      where the extension spending time during each request to evaluate
      and load Couchbase classes written in PHP. The pecl/pcs extension
      have to be installed and loaded before loading couchbase SDK.
    • PCBC-439: reset MCISCOMPRESSED before type detection.
      This fixes decoding compressed values.
    • PCBC-438: install callback for replica read command.
      This fixes getFromReplica() returning NULL.
    • Documentation updates and bug fixes
  • Druid 0.6.0
    - Fix #2 missing extension dependencies
    - Fix #3 Support PHP 7.
    - Support config curl_dns_cache_timeout,curl_connect_timeout,curl_timeout.

  • swoole 1.9.3
    - Added extension function args info
    - Added package_length_func option
    - Added http_client download method
    - Fixed issue#965
    - Fixed issue#966
    - Fixed issue#967

  • Druid 0.3.0
    - First version for pecl.net
    - Support PHP 5.*.

  • pdflib 4.1.0
    - add support for PDFlib 9.1
  • igbinary 2.0.1
    - Compatible with PHP 5.2 – 7.0
    - Fixes bug in session decoder not calling __wakeup() in php 7.0+
    - (Enhancement) Reuses identical strings when unserializing objects and arrays in php 7.0+

Source: http://www.phpdeveloper.org/news/24740

<!–
var d = new Date();
r = escape(d.getTime()*Math.random());
document.writeln('’);
//–>

Hubert Brylkowski: PHP can’t jump? Thing about recursion.

Hubert Brylkowski: PHP can’t jump? Thing about recursion.

Hubert Brylkowski has written up a post to his site looking at recursion in PHP and some of the limitations that can some with traditional methods.

Let’s get straight into the problem – assume we want to calculate nth Fibonacci number. Definition : F(n) = F(n-1) + F(n-2) with seed values F(1) = F(2) = 1 so the most intuitive way to do this is just from the definition (recursive). [...] Yay, everything works, so let’s play with bigger numbers. I would like to know the 35th Fibonacci number. On my machine it takes about 8 seconds. That sucks and takes definitely too long.

He talks about what some of the issues with this normal recursive method is (including how many times the function is called) and a possible way to resolve it. He updates this to use the BCMath handling as the numbers are starting to get larger but soon hits the max nesting level for PHP itself. Instead of traditional recursion, he suggests using a few functions/methods to to "jump" from one call to the next without one having to call the other. He includes some refactoring of this solution and a bit of benchmarking to show the performance gain over traditional methods.

Source: http://www.phpdeveloper.org/news/24739

<!–
var d = new Date();
r = escape(d.getTime()*Math.random());
document.writeln('’);
//–>

Hubert Brylkowski: PHP can’t jump? Thing about recursion.

Hubert Brylkowski: PHP can’t jump? Thing about recursion.

Hubert Brylkowski has written up a post to his site looking at recursion in PHP and some of the limitations that can some with traditional methods.

Let’s get straight into the problem – assume we want to calculate nth Fibonacci number. Definition : F(n) = F(n-1) + F(n-2) with seed values F(1) = F(2) = 1 so the most intuitive way to do this is just from the definition (recursive). [...] Yay, everything works, so let’s play with bigger numbers. I would like to know the 35th Fibonacci number. On my machine it takes about 8 seconds. That sucks and takes definitely too long.

He talks about what some of the issues with this normal recursive method is (including how many times the function is called) and a possible way to resolve it. He updates this to use the BCMath handling as the numbers are starting to get larger but soon hits the max nesting level for PHP itself. Instead of traditional recursion, he suggests using a few functions/methods to to "jump" from one call to the next without one having to call the other. He includes some refactoring of this solution and a bit of benchmarking to show the performance gain over traditional methods.

Source: http://www.phpdeveloper.org/news/24739

<!–
var d = new Date();
r = escape(d.getTime()*Math.random());
document.writeln('’);
//–>