<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Composer &#8211; My Shitty Code</title>
	<atom:link href="https://myshittycode.com/tag/composer/feed/" rel="self" type="application/rss+xml" />
	<link>https://myshittycode.com</link>
	<description>Embracing the Messiness in Search of Epic Solutions</description>
	<lastBuildDate>Fri, 06 Jan 2023 16:24:34 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.1</generator>

<image>
	<url>https://myshittycode.com/wp-content/uploads/2022/04/cropped-icon-32x32.png</url>
	<title>Composer &#8211; My Shitty Code</title>
	<link>https://myshittycode.com</link>
	<width>32</width>
	<height>32</height>
</image> 
<site xmlns="com-wordpress:feed-additions:1">205304208</site>	<item>
		<title>PHP + Composer: The Process &#8220;php -S 0.0.0.0:8080 -t public index.php&#8221; Exceeded the Timeout of 300 Seconds</title>
		<link>https://myshittycode.com/2018/03/20/php-composer-the-process-php-s-0-0-0-08080-t-public-index-php-exceeded-the-timeout-of-300-seconds/</link>
					<comments>https://myshittycode.com/2018/03/20/php-composer-the-process-php-s-0-0-0-08080-t-public-index-php-exceeded-the-timeout-of-300-seconds/#respond</comments>
		
		<dc:creator><![CDATA[Shitty Author]]></dc:creator>
		<pubDate>Wed, 21 Mar 2018 01:22:27 +0000</pubDate>
				<category><![CDATA[Programming Language]]></category>
		<category><![CDATA[Composer]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Slim]]></category>
		<guid isPermaLink="false">http://myshittycode.com/?p=1077</guid>

					<description><![CDATA[<p>PROBLEM Given the following composer.json&#8230; When running composer start&#8230; The PHP built-in web server stops with the following error message&#8230; SOLUTION There are several ways to extend the timeout value, but here is one way to do it through composer.json. To extend the timeout value from 300 seconds to 2000 seconds, add the following config [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://myshittycode.com/2018/03/20/php-composer-the-process-php-s-0-0-0-08080-t-public-index-php-exceeded-the-timeout-of-300-seconds/">PHP + Composer: The Process &#8220;php -S 0.0.0.0:8080 -t public index.php&#8221; Exceeded the Timeout of 300 Seconds</a> appeared first on <a rel="nofollow" href="https://myshittycode.com">My Shitty Code</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<h2 class="wp-block-heading">PROBLEM</h2>



<p>Given the following <b>composer.json</b>&#8230;</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: jscript; title: ; notranslate">
{
  ...
  &quot;scripts&quot;: {
    &quot;start&quot;: &quot;php -S 0.0.0.0:8080 -t public index.php&quot;
  }
}
</pre></div>


<p>When running <b>composer start</b>&#8230;</p>



<p>The PHP built-in web server stops with the following error message&#8230;</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: plain; title: ; notranslate">
&#x5B;Symfony\Component\Process\Exception\ProcessTimedOutException]
The process &quot;php -S 0.0.0.0:8080 -t public index.php&quot; exceeded the timeout of 300 seconds.
</pre></div>


<h2 class="wp-block-heading">SOLUTION</h2>



<p>There are several ways to extend the timeout value, but here is one way to do it through <b>composer.json</b>.</p>



<p>To extend the timeout value from 300 seconds to 2000 seconds, add the following <b>config</b> block in <b>composer.json</b>:-</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: jscript; highlight: [6,7,8]; title: ; notranslate">
{
  ...
  &quot;scripts&quot;: {
    &quot;start&quot;: &quot;php -S 0.0.0.0:8080 -t public index.php&quot;
  }
  &quot;config&quot;: {
    &quot;process-timeout&quot;: 2000
  }
}
</pre></div>


<p>To disable web server timeout completely, set <b>process-timeout</b> to 0:-</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: jscript; highlight: [6,7,8]; title: ; notranslate">
{
  ...
  &quot;scripts&quot;: {
    &quot;start&quot;: &quot;php -S 0.0.0.0:8080 -t public index.php&quot;
  }
  &quot;config&quot;: {
    &quot;process-timeout&quot;: 0
  }
}
</pre></div><p>The post <a rel="nofollow" href="https://myshittycode.com/2018/03/20/php-composer-the-process-php-s-0-0-0-08080-t-public-index-php-exceeded-the-timeout-of-300-seconds/">PHP + Composer: The Process &#8220;php -S 0.0.0.0:8080 -t public index.php&#8221; Exceeded the Timeout of 300 Seconds</a> appeared first on <a rel="nofollow" href="https://myshittycode.com">My Shitty Code</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://myshittycode.com/2018/03/20/php-composer-the-process-php-s-0-0-0-08080-t-public-index-php-exceeded-the-timeout-of-300-seconds/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">1077</post-id>	</item>
		<item>
		<title>Slim: Class &#8216;X&#8217; Not Found</title>
		<link>https://myshittycode.com/2018/03/14/slim-class-x-not-found/</link>
					<comments>https://myshittycode.com/2018/03/14/slim-class-x-not-found/#comments</comments>
		
		<dc:creator><![CDATA[Shitty Author]]></dc:creator>
		<pubDate>Wed, 14 Mar 2018 23:26:19 +0000</pubDate>
				<category><![CDATA[Programming Language]]></category>
		<category><![CDATA[Composer]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Slim]]></category>
		<guid isPermaLink="false">http://myshittycode.com/?p=1075</guid>

					<description><![CDATA[<p>PROBLEM Let&#8217;s assume we have the following project structure with src/model/Person.php created&#8230; &#8230; and the class may look something like this&#8230; &#8230; and it is being used in other file&#8230; When hitting the given route from the browser, we get the following error:- SOLUTION #1: Using import/require One way to solve this is to use [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://myshittycode.com/2018/03/14/slim-class-x-not-found/">Slim: Class &#8216;X&#8217; Not Found</a> appeared first on <a rel="nofollow" href="https://myshittycode.com">My Shitty Code</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<h2 class="wp-block-heading">PROBLEM</h2>



<p>Let&#8217;s assume we have the following project structure with <b>src/model/Person.php</b> created&#8230;</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: plain; highlight: [7,8]; title: ; notranslate">
.
├── composer.json
├── composer.lock
├── logs
├── public
├── src
│   ├── model
│   │   └── Person.php
│   ├── dependencies.php
│   ├── middleware.php
│   ├── routes.php
│   └── settings.php
├── templates
├── tests
└── vendor
</pre></div>


<p>&#8230; and the class may look something like this&#8230;</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: php; title: ; notranslate">
// src/main/Person.php

class Person
{
    public $name;
    public $age;

    public function __construct(string $name, int $age)
    {
        $this-&gt;name = $name;
        $this-&gt;age = $age;
    }
}
</pre></div>


<p>&#8230; and it is being used in other file&#8230;</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: php; highlight: [7]; title: ; notranslate">
// src/routes.php

use Slim\Http\Request;
use Slim\Http\Response;

$app-&gt;get(&#039;/&#x5B;{name}]&#039;, function (Request $request, Response $response, array $args) {
    $person = new Person(&#039;mike&#039;, 50);

    // ... do something
    return ...
});
</pre></div>


<p>When hitting the given route from the browser, we get the following error:-</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: plain; title: ; notranslate">
Type   : Error
Message: Class &#039;Person&#039; not found
File   : /path/to/app/src/routes.php
Line   : 7
</pre></div>


<h2 class="wp-block-heading">SOLUTION #1: Using import/require</h2>



<p>One way to solve this is to use <b>include</b> or <b>require</b> statement:-</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: php; highlight: [3]; title: ; notranslate">
// src/routes.php

require &#039;model/Person.php&#039;;

use Slim\Http\Request;
use Slim\Http\Response;

$app-&gt;get(&#039;/&#x5B;{name}]&#039;, function (Request $request, Response $response, array $args) {
    $person = new Person(&#039;mike&#039;, 50);

    // ... do something
    return ...
});
</pre></div>


<h2 class="wp-block-heading">SOLUTION #2: Using autoloading</h2>



<p>Another approach is to leverage PSR-4 autoloading.</p>



<p>First, create a namespace in <b>Person.php</b>:-</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: php; highlight: [3]; title: ; notranslate">
// src/main/Person.php

namespace App\Model;

class Person
{
    public $name;
    public $age;

    public function __construct(string $name, int $age)
    {
        $this-&gt;name = $name;
        $this-&gt;age = $age;
    }
}
</pre></div>


<p>Second, in the file that consumes that model, specify a <b>use</b> statement to alias that model so it doesn&#8217;t need to be fully qualified with the given namespace in order to use it:-</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: php; highlight: [3]; title: ; notranslate">
// src/routes.php

use App\Model\Person;
use Slim\Http\Request;
use Slim\Http\Response;

$app-&gt;get(&#039;/&#x5B;{name}]&#039;, function (Request $request, Response $response, array $args) {
    $person = new Person(&#039;mike&#039;, 50);

    // ... do something
    return ...
});
&#x5B;/code]
</pre></div>


<p>Third, in <b>composer.json</b>, create the <b>autoload</b> block and specify the namespace mapping in it:-</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: plain; highlight: [3,4,5,6,7]; title: ; notranslate">
{
  ...
  &quot;autoload&quot;: {
    &quot;psr-4&quot;: {
      &quot;App\\Model\\&quot;: &quot;src/model/&quot;
    }
  },
  &quot;autoload-dev&quot;: {
    &quot;psr-4&quot;: {
      &quot;Tests\\&quot;: &quot;tests/&quot;
    }
  },
  ...
}
</pre></div>


<p>Finally, run <b>composer dump-autoload</b> to regenerate <b>vendor/composer/autoload_psr4.php</b>. This file keeps track the list of classes needed to be included in the project.</p>
<p>The post <a rel="nofollow" href="https://myshittycode.com/2018/03/14/slim-class-x-not-found/">Slim: Class &#8216;X&#8217; Not Found</a> appeared first on <a rel="nofollow" href="https://myshittycode.com">My Shitty Code</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://myshittycode.com/2018/03/14/slim-class-x-not-found/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">1075</post-id>	</item>
	</channel>
</rss>

<!--
Performance optimized by W3 Total Cache. Learn more: https://www.boldgrid.com/w3-total-cache/?utm_source=w3tc&utm_medium=footer_comment&utm_campaign=free_plugin

Page Caching using Disk: Enhanced 
Lazy Loading (feed)
Database Caching using Disk

Served from: myshittycode.com @ 2026-02-20 00:57:30 by W3 Total Cache
-->