<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Php Profi</title>
    <description>The latest articles on Forem by Php Profi (@phpprofi).</description>
    <link>https://forem.com/phpprofi</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F45524%2F424c9e57-c554-417a-ab08-5cb58f11485c.jpg</url>
      <title>Forem: Php Profi</title>
      <link>https://forem.com/phpprofi</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/phpprofi"/>
    <language>en</language>
    <item>
      <title>Slack. Send simple message.</title>
      <dc:creator>Php Profi</dc:creator>
      <pubDate>Mon, 19 Feb 2018 22:32:43 +0000</pubDate>
      <link>https://forem.com/phpprofi/slack-send-simple-message--3pj7</link>
      <guid>https://forem.com/phpprofi/slack-send-simple-message--3pj7</guid>
      <description>&lt;p&gt;Ru: &lt;a href="http://phpprofi.ru/blogs/post/96" rel="noopener noreferrer"&gt;http://phpprofi.ru/blogs/post/96&lt;/a&gt;&lt;/p&gt;




&lt;p&gt;Recently I wrote the post about &lt;a href="https://dev.to/phpprofi/reincarnation-of-popular-php-package-for-slack-2p3i"&gt;reincarnation of popular PHP package for Slack&lt;/a&gt;, in which it was told about fork of popular package and about the resumption of support of this package. But there is nothing about its usage. So, today I want to tell about how quickly implement sending of messages to Slack with PHP.&lt;/p&gt;

&lt;h1&gt;
  
  
  Sending a message to Slack with PHP
&lt;/h1&gt;

&lt;p&gt;First, let's take a look at the implementation in general. We need to do 3 small and simple things to send a message from PHP:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://my.slack.com/services/new/incoming-webhook" rel="noopener noreferrer"&gt;Create incoming webhook&lt;/a&gt; in the Slack admin area, &amp;amp; copy the url&lt;/li&gt;
&lt;li&gt;Install &lt;a href="https://packagist.org/packages/alek13/slack" rel="noopener noreferrer"&gt;the package&lt;/a&gt; via Composer&lt;/li&gt;
&lt;li&gt;Some simple code for creating and sending massage:

&lt;ul&gt;
&lt;li&gt;Create a client by passing the hook url (copied in 1 step)&lt;/li&gt;
&lt;li&gt;Send the message&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;

&lt;p&gt;Actually, that's all. This information is enough to realize what was conceived, without reading further, but let's go through each point and reveal it in more detailed.&lt;/p&gt;

&lt;h2&gt;
  
  
  Creating incoming webhook
&lt;/h2&gt;

&lt;p&gt;The message initially sends to the Slack servers. And then these servers delivers the message to the end users. For Slack servers (and for the end user), the message you sent to these servers is an &lt;em&gt;incoming&lt;/em&gt;. Therefore, it is called &lt;em&gt;incoming&lt;/em&gt;, even though it is outgoing for you at the moment of sending. The main thing here is not to get confused. Look at this from the position of the end user, and everything falls into place.&lt;/p&gt;

&lt;p&gt;To create an incoming webhook, go to &lt;a href="https://my.slack.com/services/new/incoming-webhook" rel="noopener noreferrer"&gt;https://my.slack.com/services/new/incoming-webhook&lt;/a&gt;. You will be redirected to your workspace - the last one, the admin panel of which you visited. If you do not have access to this functionality, ask your slack administrator to create an incoming webhook and send you an &lt;code&gt;url&lt;/code&gt; to it.&lt;/p&gt;

&lt;p&gt;If you have several workspaces, go to the desired one by using the menu in the upper right corner:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F11tzzul9qowju4gb37gu.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F11tzzul9qowju4gb37gu.jpeg" width="800" height="187"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Next, you will be asked to choose the channel the messages will be delivered to:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fq9g355qjznax7y7v2qrp.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fq9g355qjznax7y7v2qrp.jpeg" width="800" height="146"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you thought that for each channel (which you want to send) you need to create a hook, then the idea is logical, but it is not necessary. When sending a message from the code, you can specify the channel to which the message should be delivered. Or do not specify the channel and the message will be sent to the &lt;strong&gt;default channel&lt;/strong&gt; that you selected in this step.&lt;/p&gt;

&lt;p&gt;After that, a new webhook will be created. You will be transferred to a page with its settings, with the information disclosed how to use it, how to generate a message and a simple example of sending it through the curl command.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fq0o1qz7o1chuaj85otck.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fq0o1qz7o1chuaj85otck.jpeg" width="800" height="166"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here you can immediately copy &lt;code&gt;Webhook URL&lt;/code&gt;, close the admin panel and proceed to install the package and code.&lt;/p&gt;

&lt;p&gt;If you want to add a bit of beauty, then fold these instructions or scroll down to the hook settings:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F02s41rkia1rj7mas35ig.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F02s41rkia1rj7mas35ig.jpeg" width="800" height="517"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here you can change:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;the default channel,&lt;/li&gt;
&lt;li&gt;regenerate &lt;code&gt;url&lt;/code&gt; (for example, if it was compromised, like this one),&lt;/li&gt;
&lt;li&gt;set "user name" - more precisely, name of your application that sends messages,&lt;/li&gt;
&lt;li&gt;select an icon or logo,&lt;/li&gt;
&lt;li&gt;... and see how the message will looks in the end.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;A lot of words, but its done in two minutes. The Slack admin area is no longer needed, we can close it. Do not forget to &lt;strong&gt;copy &lt;code&gt;hook_url&lt;/code&gt;&lt;/strong&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Installing the package
&lt;/h2&gt;

&lt;p&gt;You can install &lt;a href="https://packagist.org/packages/alek13/slack" rel="noopener noreferrer"&gt;the package&lt;/a&gt; via our favourite &lt;a href="http://getcomposer.org/" rel="noopener noreferrer"&gt;Composer&lt;/a&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;composer require alek13/slack
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1tw6n8hycarj0vbdnnyd.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1tw6n8hycarj0vbdnnyd.jpeg" width="800" height="245"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;That's all! The package is installed and ready to use.&lt;/p&gt;

&lt;h2&gt;
  
  
  Sending a message with PHP
&lt;/h2&gt;

&lt;p&gt;First, we need a client instance. To create it minimally what is required is that  &lt;code&gt;url&lt;/code&gt; to incoming webhook, which we copied when it was created.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="c1"&gt;// get from your config&lt;/span&gt;
&lt;span class="nv"&gt;$hookUrl&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'https://hooks.slack.com/services/Txxxxxxxx/Bxxxxxxxx/xxxxxxxxxxxxxxxxxxxxxxxx'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="nv"&gt;$client&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Maknz\Slack\Client&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$hookUrl&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Or you can change the default channel, user name, icon and some other settings:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="c1"&gt;// get from your config&lt;/span&gt;
&lt;span class="nv"&gt;$hookUrl&lt;/span&gt;  &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'https://hooks.slack.com/services/Txxxxxxxx/Bxxxxxxxx/xxxxxxxxxxxxxxxxxxxxxxxx'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nv"&gt;$settings&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
    &lt;span class="s1"&gt;'username'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="s1"&gt;'Php Profi Bot'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="s1"&gt;'channel'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="s1"&gt;'#general'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;];&lt;/span&gt;

&lt;span class="nv"&gt;$client&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Maknz\Slack\Client&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$hookUrl&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;$settings&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;More information about the settings, you can &lt;a href="https://github.com/alek13/slack#settings" rel="noopener noreferrer"&gt;see here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;And now just send a message:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="nv"&gt;$client&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;send&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'Hello world!'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;That's all!&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;You can see more about sending &lt;a href="https://github.com/alek13/slack#sending-messages" rel="noopener noreferrer"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Hope this article will simplify your life when you integrate your application with Slack. If something remains unclear or you just had a question, write in the our &lt;a href="https://join.slack.com/t/php-slack/shared_invite/enQtMjk1OTExNDkzMjg1LTk5ODg3MGE1OThlYzZlM2U0N2I5Y2FhM2NiYmFlMjE1MDNiOWRjMjc1ZDIwNWZlNzBkZWQ2ZWM1NzdmMjM5YzQ" rel="noopener noreferrer"&gt;Slack channel&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>php</category>
      <category>webdev</category>
      <category>opensource</category>
      <category>slack</category>
    </item>
    <item>
      <title>Асинхронный PHP: Зачем?</title>
      <dc:creator>Php Profi</dc:creator>
      <pubDate>Thu, 15 Feb 2018 19:02:41 +0000</pubDate>
      <link>https://forem.com/phpprofi/-php--4onp</link>
      <guid>https://forem.com/phpprofi/-php--4onp</guid>
      <description>&lt;p&gt;Асинхронное программирование сегодня достаточно востребованно. Особенно в веб-разработке, где скорость реагирования приложения играет огромную роль. Никто не хочет тратить свое время и ожидать подвисшее приложение, пока вы выполняете несколько запросов к базе, отправляете электронное письмо или запускаете другие потенциально длительные задачи. Пользователи хотят получать ответы на свои действия, и они хотят, чтобы эти ответы происходили мгновенно. Когда ваше приложение становится медленным, вы начнете терять своих клиентов. После того, как пользователь сталкивается с подвисанием приложения, в большинстве случаев он или она просто закрывает его и никогда не возвращается. Когда интерфейс зависает, с точки зрения пользователя не ясно - толи ваше приложение поломанано, толи оно выполняет какие-то длительные задачи и на них требуется некоторое время.&lt;/p&gt;




&lt;p&gt;Читать далее: &lt;a href="http://phpprofi.ru/blogs/post/100"&gt;http://phpprofi.ru/blogs/post/100&lt;/a&gt;&lt;/p&gt;




&lt;p&gt;En: &lt;a href="http://sergeyzhuk.me/2018/02/02/why-asynchronous-php/"&gt;http://sergeyzhuk.me/2018/02/02/why-asynchronous-php/&lt;/a&gt;&lt;/p&gt;

</description>
      <category>php</category>
      <category>webdev</category>
      <category>reactphp</category>
      <category>async</category>
    </item>
    <item>
      <title>Mockery: частичные двойники (mock'и)</title>
      <dc:creator>Php Profi</dc:creator>
      <pubDate>Wed, 07 Feb 2018 20:52:53 +0000</pubDate>
      <link>https://forem.com/phpprofi/mockery---mock-1him</link>
      <guid>https://forem.com/phpprofi/mockery---mock-1him</guid>
      <description>&lt;p&gt;Работая со старым кодом, я часто сталкиваюсь с таким классом, который расширяет большой базовый абстрактный класс, а методы этого класса вызывают методы того большого базового абстрактного класса, который делает очень много вещей. Я сам писал такие классы и методы в прошлом. Век живи, век учись.&lt;/p&gt;

&lt;p&gt;Одна из самых больших проблем с этим кодом заключается в том, что это довольно трудно тестировать. Методы из базового класса могут возвращать другие объекты, побочно затрагивают другие части кода (или вызывают сервисы), делают http-запросы...&lt;/p&gt;




&lt;p&gt;Читать далее: &lt;a href="http://phpprofi.ru/blogs/post/99"&gt;http://phpprofi.ru/blogs/post/99&lt;/a&gt;&lt;/p&gt;




&lt;p&gt;En: &lt;a href="https://robertbasic.com/blog/mockery-partial-mocks/"&gt;https://robertbasic.com/blog/mockery-partial-mocks/&lt;/a&gt;&lt;/p&gt;

</description>
      <category>php</category>
      <category>webdev</category>
      <category>testing</category>
      <category>mockery</category>
    </item>
    <item>
      <title>Test Coverage: Интеграция CodeClimate и Travis CI</title>
      <dc:creator>Php Profi</dc:creator>
      <pubDate>Wed, 07 Feb 2018 16:09:51 +0000</pubDate>
      <link>https://forem.com/phpprofi/test-coverage--codeclimate--travis-ci-151d</link>
      <guid>https://forem.com/phpprofi/test-coverage--codeclimate--travis-ci-151d</guid>
      <description>&lt;p&gt;Когда вы разрабатываете проект с открытым исходным кодом, считается хорошей практикой иметь высокое покрытие тестами, чтобы сообщество могло чувствовать себя в безопасности, используя ваш код в своих проектах. Существуют онлайн-сервисы, которые могут анализировать качество вашего кода и предоставляют отчёты и рекомендации. Одним из самых популярных является &lt;a href="http://codeclimate.com"&gt;Code Climate&lt;/a&gt;. Этот сервис не запускает ваши тесты, но вы можете использовать один из инструментов непрерывной интеграции(CI) для их запуска, а затем отправлять его результат в Code Climate. В этой статье будет показано, как использовать &lt;a href="https://travis-ci.org"&gt;Travis CI&lt;/a&gt; для запуска тестов и данные о покрытии тестами в &lt;a href="http://codeclimate.com"&gt;CodeClimate&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--wmlks2-e--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/http://sergeyzhuk.me/assets/images/posts/travisci-codeclimate/travis-loves-code-climate.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--wmlks2-e--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/http://sergeyzhuk.me/assets/images/posts/travisci-codeclimate/travis-loves-code-climate.png" alt="logo"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;p&gt;Читать далее: &lt;a href="http://phpprofi.ru/blogs/post/98"&gt;http://phpprofi.ru/blogs/post/98&lt;/a&gt;&lt;/p&gt;




&lt;p&gt;En: &lt;a href="http://sergeyzhuk.me/2018/01/11/travis-with-codeclimate/"&gt;http://sergeyzhuk.me/2018/01/11/travis-with-codeclimate/&lt;/a&gt;&lt;/p&gt;

</description>
      <category>php</category>
      <category>testing</category>
      <category>webdev</category>
      <category>opensource</category>
    </item>
    <item>
      <title>GroupBy по нескольким значениям в Laravel</title>
      <dc:creator>Php Profi</dc:creator>
      <pubDate>Mon, 05 Feb 2018 13:17:38 +0000</pubDate>
      <link>https://forem.com/phpprofi/groupby-----laravel-185</link>
      <guid>https://forem.com/phpprofi/groupby-----laravel-185</guid>
      <description>&lt;p&gt;В Laravel начиная с версии 5.5.29 можно группировать коллекции по нескольким критериям. Давайте посмотрим, что это означает и как это работает.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--TgbbA5Zq--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/http://phpprofi.ru/resources/img/blogs/bf9c09d1-c041-48b9-9414-73b4d0464031.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--TgbbA5Zq--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/http://phpprofi.ru/resources/img/blogs/bf9c09d1-c041-48b9-9414-73b4d0464031.jpeg" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Подготовка
&lt;/h2&gt;

&lt;p&gt;Итак, эта статья о новой функциональности в фреймворке Laravel. Но прежде чем мы посмотрим как она работет сейчас, давайте посмотрим как она работала раньше. Метод &lt;strong&gt;&lt;code&gt;groupBy&lt;/code&gt;&lt;/strong&gt; является методом класса &lt;strong&gt;&lt;code&gt;Collection&lt;/code&gt;&lt;/strong&gt;. Для наших примеров я создам немного данных, с которыми мы будем работать. &lt;code&gt;Students&lt;/code&gt; будет фабрикой состояний для передаваемого класса &lt;code&gt;User&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// Default user factory which comes with Laravel
$factory-&amp;gt;define(App\User::class, function (Faker $faker) {
    return [
        'name' =&amp;gt; $faker-&amp;gt;name,
        'email' =&amp;gt; $faker-&amp;gt;unique()-&amp;gt;safeEmail,
        'password' =&amp;gt; '$2y$10$TKh8H1.PfQx37YgCzwiKb.KjNyWgaHb9cbcoQgdIVFlYg7B77UdFm', // secret
        'remember_token' =&amp;gt; str_random(10),
    ];
});

// Our new students state
$factory-&amp;gt;state(App\User::class, 'students', function (Faker $faker) {
    return [
        'skilllevel' =&amp;gt; collect(['beginner', 'intermediate', 'professional'])-&amp;gt;random(),
        'teacher' =&amp;gt; collect(['Peter', 'Markus', 'Chris'])-&amp;gt;random(),
    ];
});
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;p&gt;Читать далее: &lt;a href="http://phpprofi.ru/blogs/post/97"&gt;http://phpprofi.ru/blogs/post/97&lt;/a&gt;&lt;/p&gt;




&lt;p&gt;En: &lt;a href="https://christoph-rumpel.com/2018/01/groupby-multiple-levels-in-laravel"&gt;https://christoph-rumpel.com/2018/01/groupby-multiple-levels-in-laravel&lt;/a&gt;&lt;/p&gt;

</description>
      <category>php</category>
      <category>webdev</category>
      <category>laravel</category>
      <category>groupby</category>
    </item>
    <item>
      <title>Reincarnation of popular PHP package for Slack</title>
      <dc:creator>Php Profi</dc:creator>
      <pubDate>Thu, 25 Jan 2018 20:43:41 +0000</pubDate>
      <link>https://forem.com/phpprofi/reincarnation-of-popular-php-package-for-slack-2p3i</link>
      <guid>https://forem.com/phpprofi/reincarnation-of-popular-php-package-for-slack-2p3i</guid>
      <description>&lt;p&gt;Hi, everyone!&lt;/p&gt;

&lt;p&gt;Today I want to tell about small but popular open source package and ask some help from you.&lt;/p&gt;

&lt;h1&gt;
  
  
  Slack
&lt;/h1&gt;

&lt;p&gt;I think most of you use Slack in your teams for simplifying work on your project. For this, Slack is very great and helpful.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fp0oseumwrf0v07lxczrk.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fp0oseumwrf0v07lxczrk.jpeg" width="800" height="316"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You can create several channels in it for different departments or/and different subteams — for example, for frontend, backend, devops,.. You can connect all kinds of already implemented integrations for every taste: Bitbucket, GitHub, GitLab, Jira, Trello — all that you could only think about, probably already implemented and there is an integration. And if not, there is great API with help of which you can put into effect all your ideas easily. And most likely you’ve already implemented something for Slack at least once.&lt;/p&gt;

&lt;p&gt;Also you can connect applications or so-called bots and for example quickly get instant voting or weather summary. And you can write your own. And so on…&lt;/p&gt;

&lt;p&gt;Besides you can write a simple small API in your application that will receive commands from Slack and do some actions. In one of my projects I implement many abilities of admin panel via Slack commands. And it turned out very handy.&lt;/p&gt;

&lt;p&gt;However we more often use Slack API for monitoring (severs/logs/…) and for notifying about some events in our application.&lt;/p&gt;

&lt;h1&gt;
  
  
  PHP package
&lt;/h1&gt;

&lt;p&gt;If you use Slack in your team for monitoring, notifications, commands or other purposes you primarily like me try to find existing package that easy to install and use. And like me find great and popular package maknz/slack.&lt;/p&gt;

&lt;p&gt;This package at the moment has about &lt;strong&gt;2 millions&lt;/strong&gt; installs, almost &lt;strong&gt;1000 stars&lt;/strong&gt; and &lt;strong&gt;150 forks&lt;/strong&gt;. This package has &lt;strong&gt;73 depended&lt;/strong&gt; packages, including all kinds of integrations with different frameworks (Laravel, Symfony, Yii, …) and automations like PHP-CI. Lets consent that’s fairly well.&lt;/p&gt;

&lt;p&gt;read more: &lt;a href="https://medium.com/@alek13.me/reincarnation-of-popular-php-package-for-slack-cb2e8db98a91" rel="noopener noreferrer"&gt;https://medium.com/@alek13.me/reincarnation-of-popular-php-package-for-slack-cb2e8db98a91&lt;/a&gt;&lt;/p&gt;

</description>
      <category>php</category>
      <category>slack</category>
      <category>package</category>
      <category>opensource</category>
    </item>
    <item>
      <title>Качество кода: 'взбиваемость' (churn) и сложность (complexity). Как отслеживать легаси.</title>
      <dc:creator>Php Profi</dc:creator>
      <pubDate>Mon, 22 Jan 2018 15:06:56 +0000</pubDate>
      <link>https://forem.com/phpprofi/---churn---complexity----29j1</link>
      <guid>https://forem.com/phpprofi/---churn---complexity----29j1</guid>
      <description>&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--EK7bZCeK--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://matthiasnoback.nl/assets/2018/01/churn.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--EK7bZCeK--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://matthiasnoback.nl/assets/2018/01/churn.png" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Cложность кода (code complexity)
&lt;/h2&gt;

&lt;p&gt;Сложность часто измеряется путем вычисления &lt;a href="https://ru.wikipedia.org/wiki/%D0%A6%D0%B8%D0%BA%D0%BB%D0%BE%D0%BC%D0%B0%D1%82%D0%B8%D1%87%D0%B5%D1%81%D0%BA%D0%B0%D1%8F_%D1%81%D0%BB%D0%BE%D0%B6%D0%BD%D0%BE%D1%81%D1%82%D1%8C"&gt;цикломатической сложности&lt;/a&gt; на единицу кода. Показатель можно рассчитать, принимая все ветви кода во внимание.&lt;/p&gt;

&lt;p&gt;Сложность кода является показателем для нескольких вещей:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;u&gt;На сколько трудно понять кусок кода&lt;/u&gt;. Большое значение показателя говорит о многочисленном ветвлении в коде. При чтении кода, программист должен отслеживать все эти ветки, чтобы понять все различные пути, в которые может "зайти" приложение при исполнении.&lt;/li&gt;
&lt;li&gt;
&lt;u&gt;На сколько трудно протестировать этот кусок кода&lt;/u&gt;. Большое значение показателя указывает на множество ветвей кода, и для того, чтобы полностью протестировать этот кусок кода, все эти ветви должны быть покрыты отдельно.&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;Читать далее: &lt;a href="http://phpprofi.ru/blogs/post/95"&gt;http://phpprofi.ru/blogs/post/95&lt;/a&gt;&lt;/p&gt;




&lt;p&gt;En: &lt;a href="https://matthiasnoback.nl/2018/01/churn-legacy-code/"&gt;https://matthiasnoback.nl/2018/01/churn-legacy-code/&lt;/a&gt;&lt;/p&gt;

</description>
      <category>php</category>
      <category>testing</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Не пишите бесполезные unit-тесты</title>
      <dc:creator>Php Profi</dc:creator>
      <pubDate>Fri, 19 Jan 2018 20:42:32 +0000</pubDate>
      <link>https://forem.com/phpprofi/---unit--el1</link>
      <guid>https://forem.com/phpprofi/---unit--el1</guid>
      <description>&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2pl5zl2lzw2ld0rvmqht.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2pl5zl2lzw2ld0rvmqht.jpeg" alt="PhpUnit" width="800" height="300"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;На днях я наткнулся на следующий код в проекте:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class Users
{
    public function __construct(PDO $pdo)
    {
        $this-&amp;gt;pdo = $pdo;
    }

    public function getAllUsers()
    {
        $stmt = $this-&amp;gt;pdo-&amp;gt;prepare('SELECT * FROM users');
        return $stmt-&amp;gt;fetchAll();
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt; &lt;/p&gt;

&lt;p&gt;И был вот такой тест для проверки этого кода:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class UserTest extends TestCase
{
    public function testGetAllUsers()
    {
        $pdo = m::mock(PDO::class);
        $stmt = m::mock(PDOStatement::class);

        $pdo-&amp;gt;shouldReceive(‘prepare’)-&amp;gt;andReturn($stmt);
        $pdoStmt-&amp;gt;shouldReceive(‘fetchAll’)-&amp;gt;andReturn($userArray);

        $users = new Users($pdo);
        $result = $users-&amp;gt;getAllUsers();

        $this-&amp;gt;assertEquals($userArray, $users);
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;Обратите внимание, что я опустил остальную часть класса User, а также массив пользователей, который возвращается в тесте.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Этот тест на самом деле даёт нам 100%-ое покрытие кода в методе &lt;code&gt;getAllUsers()&lt;/code&gt;. Но, к сожалению, для любой практической цели, этот тест полностью бесполезен.&lt;/p&gt;




&lt;p&gt;Читать далее: &lt;a href="http://phpprofi.ru/blogs/post/94" rel="noopener noreferrer"&gt;http://phpprofi.ru/blogs/post/94&lt;/a&gt;&lt;/p&gt;




&lt;p&gt;En: &lt;a href="https://www.brandonsavage.net/dont-write-useless-unit-tests/" rel="noopener noreferrer"&gt;https://www.brandonsavage.net/dont-write-useless-unit-tests/&lt;/a&gt;&lt;/p&gt;

</description>
      <category>php</category>
      <category>webdev</category>
      <category>testing</category>
      <category>mockery</category>
    </item>
    <item>
      <title>Использование Laravel'овских строк перевода(локализации) во Vue.js</title>
      <dc:creator>Php Profi</dc:creator>
      <pubDate>Thu, 18 Jan 2018 04:01:42 +0000</pubDate>
      <link>https://forem.com/phpprofi/-laravel----vuejs-398l</link>
      <guid>https://forem.com/phpprofi/-laravel----vuejs-398l</guid>
      <description>&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F800%2F1%2A0PQd6Z3ddIPEr8eVvrkoBw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F800%2F1%2A0PQd6Z3ddIPEr8eVvrkoBw.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Одина из проблем, с которой вам придется столкнуться при создании мултиязычного сайта — это то, как держать в порядке ваши строки переводов для серверной стороны и для JavaScript компонентов. Я собираюсь продемонстрировать основные приёмы реализации этого, используя в моих примерах Laravel и Vue.js.&lt;/p&gt;




&lt;p&gt;Читать далее: &lt;a href="http://phpprofi.ru/blogs/post/92" rel="noopener noreferrer"&gt;http://phpprofi.ru/blogs/post/92&lt;/a&gt;&lt;/p&gt;




&lt;p&gt;En: &lt;a href="https://medium.com/@codebyjeff/using-laravel-translation-strings-in-vue-js-e2e35b7aafca" rel="noopener noreferrer"&gt;https://medium.com/@codebyjeff/using-laravel-translation-strings-in-vue-js-e2e35b7aafca&lt;/a&gt;&lt;/p&gt;

</description>
      <category>php</category>
      <category>laravel</category>
      <category>vue</category>
    </item>
    <item>
      <title>Реинкарнация популярного PHP-пакета для Slack</title>
      <dc:creator>Php Profi</dc:creator>
      <pubDate>Wed, 10 Jan 2018 19:09:55 +0000</pubDate>
      <link>https://forem.com/phpprofi/--php---slack-4k2m</link>
      <guid>https://forem.com/phpprofi/--php---slack-4k2m</guid>
      <description>&lt;p&gt;Всем привет!&lt;/p&gt;

&lt;p&gt;Сегодня я хочу рассказать о небольшом, но популярном open source пакете и попросить у вас помощи и поддержки.&lt;/p&gt;

&lt;h2&gt;
  
  
  Slack
&lt;/h2&gt;

&lt;p&gt;Все вы наверняка использовали &lt;a href="https://slack.com/" rel="noopener noreferrer"&gt;Slack&lt;/a&gt; в своих командах для упрощения работы над проектом. В этом плане Slack - очень удобная штука.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/http%3A%2F%2Fphpprofi.ru%2Fresources%2Fimg%2Fblogs%2Fb8050f01-7610-42fe-beb3-8c31348d0018.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/http%3A%2F%2Fphpprofi.ru%2Fresources%2Fimg%2Fblogs%2Fb8050f01-7610-42fe-beb3-8c31348d0018.jpeg" alt="Php Slack package"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;p&gt;Читать далее: &lt;a href="http://phpprofi.ru/blogs/post/93" rel="noopener noreferrer"&gt;http://phpprofi.ru/blogs/post/93&lt;/a&gt;&lt;/p&gt;




&lt;p&gt;En: &lt;a href="https://dev.to/phpprofi/reincarnation-of-popular-php-package-for-slack-2p3i"&gt;https://dev.to/phpprofi/reincarnation-of-popular-php-package-for-slack-2p3i&lt;/a&gt;&lt;/p&gt;

</description>
      <category>php</category>
      <category>opensource</category>
      <category>slack</category>
      <category>package</category>
    </item>
    <item>
      <title>Подключение к Redis через Unix-сокеты в Docker</title>
      <dc:creator>Php Profi</dc:creator>
      <pubDate>Thu, 28 Dec 2017 00:52:51 +0000</pubDate>
      <link>https://forem.com/phpprofi/--redis--unix---docker-823</link>
      <guid>https://forem.com/phpprofi/--redis--unix---docker-823</guid>
      <description>&lt;p&gt;Подключение к Redis через Unix-сокеты, как правило, быстрее, чем подключение через TCP/IP.&lt;/p&gt;

&lt;p&gt;Это потому, что в целом, Unix-сокеты имеют гораздо меньше накладных расходов. Они, по сути, просто файлы, которые могут читать Unix-подобные системы. Недостатком этого является то, что возможны только локальные подключения.&lt;/p&gt;

&lt;p&gt;Имея 10М+ скачиваний, &lt;a href="https://hub.docker.com/_/redis/" rel="noopener noreferrer"&gt;&lt;code&gt;redis&lt;/code&gt;&lt;/a&gt; является &lt;a href="https://hub.docker.com/explore/" rel="noopener noreferrer"&gt;четвертым&lt;/a&gt; среди самых скачиваемых Docker-образов, и большинство систем настраивают подключение к Redis через Docker'овский встроеный сетевой TCP-мост.&lt;/p&gt;

&lt;p&gt;Docker'овский собственный сетевой TCP-мост — это, конечно, хорошо и прекрасно, но не хотели бы вы выжать еще немного скорости?&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/http%3A%2F%2Fphpprofi.ru%2F%2Fresources%2Fimg%2Fblogs%2F3628892c-62be-4c36-8b66-5dc2aa3388e5.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/http%3A%2F%2Fphpprofi.ru%2F%2Fresources%2Fimg%2Fblogs%2F3628892c-62be-4c36-8b66-5dc2aa3388e5.jpeg"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;p&gt;Читать далее: &lt;a href="http://phpprofi.ru/blogs/post/91" rel="noopener noreferrer"&gt;http://phpprofi.ru/blogs/post/91&lt;/a&gt;&lt;/p&gt;




&lt;p&gt;En: &lt;a href="https://medium.com/@jonbaldie/how-to-connect-to-redis-with-unix-sockets-in-docker-9e94e01b7acd" rel="noopener noreferrer"&gt;https://medium.com/@jonbaldie/how-to-connect-to-redis-with-unix-sockets-in-docker-9e94e01b7acd&lt;/a&gt;&lt;/p&gt;

</description>
      <category>php</category>
      <category>webdev</category>
      <category>redis</category>
      <category>docker</category>
    </item>
    <item>
      <title>Асинхронный параллельный запуск кода в PHP на примере Laravel Collection</title>
      <dc:creator>Php Profi</dc:creator>
      <pubDate>Mon, 25 Dec 2017 19:12:37 +0000</pubDate>
      <link>https://forem.com/phpprofi/-----php---laravel-collection-5gg1</link>
      <guid>https://forem.com/phpprofi/-----php---laravel-collection-5gg1</guid>
      <description>&lt;p&gt;Фреймворк Laravel имеет отличный &lt;a href="https://laravel.com/docs/5.5/collections" rel="noopener noreferrer"&gt;класс для работы с коллекциями&lt;/a&gt;, который имеет &lt;a href="https://laravel.com/docs/5.5/collections#available-methods" rel="noopener noreferrer"&gt;много полезных операций&lt;/a&gt;. Класс также является &lt;a href="https://laravel.com/docs/5.5/collections#extending-collections" rel="noopener noreferrer"&gt;macroable&lt;/a&gt;. Это означает, что к нему можно добавлять функции во время выполнения путем вызова его метода &lt;code&gt;macro&lt;/code&gt; и передачи названия и замыкания. В наших проектах мы, как правило, пишем один и тот же макрос снова и снова. Вот почему мы вынесли эти макросы в &lt;a href="https://github.com/spatie/laravel-collection-macros" rel="noopener noreferrer"&gt;пакет laravel-collection-macros&lt;/a&gt;, так что вы можете их использовать.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fr2zia5q272qdzpzk6tn1.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fr2zia5q272qdzpzk6tn1.jpeg" width="540" height="200"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;В этом посте я хотел бы поговорить немного о &lt;a href="https://github.com/spatie/laravel-collection-macros#parallelmap" rel="noopener noreferrer"&gt;новом макросе&lt;/a&gt;,  называемом &lt;code&gt;parallelMap&lt;/code&gt;.&lt;/p&gt;




&lt;p&gt;Читать далее: &lt;a href="http://phpprofi.ru/blogs/post/90" rel="noopener noreferrer"&gt;http://phpprofi.ru/blogs/post/90&lt;/a&gt;&lt;/p&gt;




&lt;p&gt;En: &lt;a href="https://murze.be/an-async-map-function" rel="noopener noreferrer"&gt;https://murze.be/an-async-map-function&lt;/a&gt;&lt;/p&gt;

</description>
      <category>php</category>
      <category>laravel</category>
      <category>async</category>
      <category>parallel</category>
    </item>
  </channel>
</rss>
