Advertisement
Guest User

Confused

a guest
Sep 29th, 2016
423
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 60.20 KB | None | 0 0
  1. <?xml version="1.0" encoding="utf-8"?>
  2.  
  3. <feed xmlns="http://www.w3.org/2005/Atom" xmlns:creativeCommons="http://backend.userland.com/creativeCommonsRssModule" xmlns:re="http://purl.org/atompub/rank/1.0">
  4.     <title type="text">Featured questions tagged php - Stack Overflow</title>
  5.     <link rel="self" href="http://stackoverflow.com/feeds/tag?tagnames=php&amp;sort=featured" type="application/atom+xml" />
  6.     <link rel="alternate" href="http://stackoverflow.com/questions/tagged/?tagnames=php&amp;sort=featured" type="text/html" />
  7.     <subtitle>most recent 30 from stackoverflow.com</subtitle>
  8.     <updated>2016-09-29T06:46:21Z</updated>
  9.     <id>http://stackoverflow.com/feeds/tag?tagnames=php&amp;sort=featured</id>
  10.     <creativeCommons:license>http://www.creativecommons.org/licenses/by-sa/3.0/rdf</creativeCommons:license>
  11.     <entry>
  12.         <id>http://stackoverflow.com/q/4029341</id>
  13.         <re:rank scheme="http://stackoverflow.com">43</re:rank>
  14.         <title type="text">DOM parser that allows HTML5-style &lt;/ in &lt;script&gt; tag</title>
  15.             <category scheme="http://stackoverflow.com/tags" term="php" />
  16.             <category scheme="http://stackoverflow.com/tags" term="dom" />
  17.             <category scheme="http://stackoverflow.com/tags" term="html5" />
  18.         <author>
  19.             <name>Annika Backstrom</name>
  20.             <uri>http://stackoverflow.com/users/7675</uri>
  21.         </author>
  22.         <link rel="alternate" href="http://stackoverflow.com/questions/4029341/dom-parser-that-allows-html5-style-in-script-tag" />
  23.         <published>2016-09-22T09:28:50Z</published>
  24.         <updated>2016-09-27T09:38:41Z</updated>
  25.         <summary type="html">
  26.            
  27.  
  28.             &lt;p&gt;&lt;strong&gt;Update&lt;/strong&gt;: &lt;code&gt;html5lib&lt;/code&gt; (bottom of question) seems to get close, I just need to improve my understanding of how it&#39;s used.&lt;/p&gt;
  29.  
  30. &lt;p&gt;I am attempting to find an HTML5-compatible DOM parser for PHP 5.3. In particular, I need to access the following HTML-like CDATA within a script tag:&lt;/p&gt;
  31.  
  32. &lt;pre&gt;&lt;code&gt;&amp;lt;script type=&quot;text/x-jquery-tmpl&quot; id=&quot;foo&quot;&amp;gt;
  33.     &amp;lt;table&amp;gt;&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;${name}&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&amp;lt;/table&amp;gt;
  34. &amp;lt;/script&amp;gt;
  35. &lt;/code&gt;&lt;/pre&gt;
  36.  
  37. &lt;p&gt;Most parsers will end parsing prematurely because HTML 4.01 &lt;a href=&quot;http://www.w3.org/TR/1999/REC-html401-19991224/appendix/notes.html#notes-specifying-data&quot;&gt;ends script tag parsing&lt;/a&gt; when it finds ETAGO (&lt;code&gt;&amp;lt;/&lt;/code&gt;) inside a &lt;code&gt;&amp;lt;script&amp;gt;&lt;/code&gt; tag. However, HTML5 &lt;a href=&quot;http://www.w3.org/TR/2010/WD-html5-20100624/scripting-1.html#restrictions-for-contents-of-script-elements&quot;&gt;allows for &lt;code&gt;&amp;lt;/&lt;/code&gt;&lt;/a&gt; before &lt;code&gt;&amp;lt;/script&amp;gt;&lt;/code&gt;. All of the parsers I have tried so far have either failed, or they are so poorly documented that I haven&#39;t figured out if they work or not.&lt;/p&gt;
  38.  
  39. &lt;p&gt;My requirements:&lt;/p&gt;
  40.  
  41. &lt;ol&gt;
  42. &lt;li&gt;Real parser, not regex hacks.&lt;/li&gt;
  43. &lt;li&gt;Ability to load full pages or HTML fragments.&lt;/li&gt;
  44. &lt;li&gt;Ability to pull script &lt;em&gt;contents&lt;/em&gt; back out, selecting by the tag&#39;s id attribute.&lt;/li&gt;
  45. &lt;/ol&gt;
  46.  
  47. &lt;p&gt;Input:&lt;/p&gt;
  48.  
  49. &lt;pre&gt;&lt;code&gt;&amp;lt;script id=&quot;foo&quot;&amp;gt;&amp;lt;td&amp;gt;bar&amp;lt;/td&amp;gt;&amp;lt;/script&amp;gt;
  50. &lt;/code&gt;&lt;/pre&gt;
  51.  
  52. &lt;p&gt;Example of failing output (no closing &lt;code&gt;&amp;lt;/td&amp;gt;&lt;/code&gt;):&lt;/p&gt;
  53.  
  54. &lt;pre&gt;&lt;code&gt;&amp;lt;script id=&quot;foo&quot;&amp;gt;&amp;lt;td&amp;gt;bar&amp;lt;/script&amp;gt;
  55. &lt;/code&gt;&lt;/pre&gt;
  56.  
  57. &lt;p&gt;Some parsers and their results:&lt;/p&gt;
  58.  
  59. &lt;p&gt;&lt;br&gt;&lt;/p&gt;
  60.  
  61. &lt;h2&gt;&lt;a href=&quot;http://php.net/manual/en/class.domdocument.php&quot;&gt;DOMDocument&lt;/a&gt; (fails)&lt;/h2&gt;
  62.  
  63. &lt;p&gt;Source:&lt;/p&gt;
  64.  
  65. &lt;pre&gt;&lt;code&gt;&amp;lt;?php
  66.  
  67. header(&#39;Content-type: text/plain&#39;);
  68. $d = new DOMDocument;
  69. $d-&amp;gt;loadHTML(&#39;&amp;lt;script id=&quot;foo&quot;&amp;gt;&amp;lt;td&amp;gt;bar&amp;lt;/td&amp;gt;&amp;lt;/script&amp;gt;&#39;);
  70. echo $d-&amp;gt;saveHTML();
  71. &lt;/code&gt;&lt;/pre&gt;
  72.  
  73. &lt;p&gt;Output:&lt;/p&gt;
  74.  
  75. &lt;pre&gt;&lt;code&gt;Warning: DOMDocument::loadHTML(): Unexpected end tag : td in Entity, line: 1 in /home/adam/public_html/2010/10/26/dom.php on line 5
  76. &amp;lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD HTML 4.0 Transitional//EN&quot; &quot;http://www.w3.org/TR/REC-html40/loose.dtd&quot;&amp;gt;
  77. &amp;lt;html&amp;gt;&amp;lt;head&amp;gt;&amp;lt;script id=&quot;foo&quot;&amp;gt;&amp;lt;td&amp;gt;bar&amp;lt;/script&amp;gt;&amp;lt;/head&amp;gt;&amp;lt;/html&amp;gt;
  78. &lt;/code&gt;&lt;/pre&gt;
  79.  
  80. &lt;p&gt;&lt;br&gt;&lt;/p&gt;
  81.  
  82. &lt;h2&gt;&lt;a href=&quot;http://fluentdom.github.com/&quot;&gt;FluentDOM&lt;/a&gt; (fails)&lt;/h2&gt;
  83.  
  84. &lt;p&gt;Source:&lt;/p&gt;
  85.  
  86. &lt;pre&gt;&lt;code&gt;&amp;lt;?php
  87.  
  88. header(&#39;Content-type: text/plain&#39;);
  89. require_once &#39;FluentDOM/src/FluentDOM.php&#39;;
  90. $html = &quot;&amp;lt;html&amp;gt;&amp;lt;head&amp;gt;&amp;lt;/head&amp;gt;&amp;lt;body&amp;gt;&amp;lt;script id=&#39;foo&#39;&amp;gt;&amp;lt;td&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;/script&amp;gt;&amp;lt;/body&amp;gt;&amp;lt;/html&amp;gt;&quot;;
  91. echo FluentDOM($html, &#39;text/html&#39;);
  92. &lt;/code&gt;&lt;/pre&gt;
  93.  
  94. &lt;p&gt;Output:&lt;/p&gt;
  95.  
  96. &lt;pre&gt;&lt;code&gt;&amp;lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD HTML 4.0 Transitional//EN&quot; &quot;http://www.w3.org/TR/REC-html40/loose.dtd&quot;&amp;gt;
  97. &amp;lt;html&amp;gt;&amp;lt;head&amp;gt;&amp;lt;/head&amp;gt;&amp;lt;body&amp;gt;&amp;lt;script id=&quot;foo&quot;&amp;gt;&amp;lt;td&amp;gt;&amp;lt;/script&amp;gt;&amp;lt;/body&amp;gt;&amp;lt;/html&amp;gt;
  98. &lt;/code&gt;&lt;/pre&gt;
  99.  
  100. &lt;p&gt;&lt;br&gt;&lt;/p&gt;
  101.  
  102. &lt;h2&gt;&lt;a href=&quot;http://code.google.com/p/phpquery/&quot;&gt;phpQuery&lt;/a&gt; (fails)&lt;/h2&gt;
  103.  
  104. &lt;p&gt;Source:&lt;/p&gt;
  105.  
  106. &lt;pre&gt;&lt;code&gt;&amp;lt;?php
  107.  
  108. header(&#39;Content-type: text/plain&#39;);
  109.  
  110. require_once &#39;phpQuery.php&#39;;
  111.  
  112. phpQuery::newDocumentHTML(&amp;lt;&amp;lt;&amp;lt;EOF
  113. &amp;lt;script type=&quot;text/x-jquery-tmpl&quot; id=&quot;foo&quot;&amp;gt;
  114. &amp;lt;td&amp;gt;test&amp;lt;/td&amp;gt;
  115. &amp;lt;/script&amp;gt;
  116. EOF
  117. );
  118. &lt;/code&gt;&lt;/pre&gt;
  119.  
  120. &lt;p&gt;echo (string)pq(&#39;#foo&#39;);&lt;/p&gt;
  121.  
  122. &lt;p&gt;Output:&lt;/p&gt;
  123.  
  124. &lt;pre&gt;&lt;code&gt;&amp;lt;script type=&quot;text/x-jquery-tmpl&quot; id=&quot;foo&quot;&amp;gt;
  125. &amp;lt;td&amp;gt;test
  126. &amp;lt;/script&amp;gt;
  127. &lt;/code&gt;&lt;/pre&gt;
  128.  
  129. &lt;p&gt;&lt;br&gt;&lt;/p&gt;
  130.  
  131. &lt;h2&gt;&lt;a href=&quot;http://code.google.com/p/html5lib/&quot;&gt;html5lib&lt;/a&gt; (passes)&lt;/h2&gt;
  132.  
  133. &lt;p&gt;Possibly promising. Can I get at the contents of the &lt;code&gt;script#foo&lt;/code&gt; tag?&lt;/p&gt;
  134.  
  135. &lt;p&gt;Source:&lt;/p&gt;
  136.  
  137. &lt;pre&gt;&lt;code&gt;&amp;lt;?php
  138.  
  139. header(&#39;Content-type: text/plain&#39;);
  140.  
  141. include &#39;HTML5/Parser.php&#39;;
  142.  
  143. $html = &quot;&amp;lt;!DOCTYPE html&amp;gt;&amp;lt;html&amp;gt;&amp;lt;head&amp;gt;&amp;lt;/head&amp;gt;&amp;lt;body&amp;gt;&amp;lt;script id=&#39;foo&#39;&amp;gt;&amp;lt;td&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;/script&amp;gt;&amp;lt;/body&amp;gt;&amp;lt;/html&amp;gt;&quot;;
  144. $d = HTML5_Parser::parse($html);
  145.  
  146. echo $d-&amp;gt;saveHTML();
  147. &lt;/code&gt;&lt;/pre&gt;
  148.  
  149. &lt;p&gt;Output:&lt;/p&gt;
  150.  
  151. &lt;pre&gt;&lt;code&gt;&amp;lt;html&amp;gt;&amp;lt;head&amp;gt;&amp;lt;/head&amp;gt;&amp;lt;body&amp;gt;&amp;lt;script id=&quot;foo&quot;&amp;gt;&amp;lt;td&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;/script&amp;gt;&amp;lt;/body&amp;gt;&amp;lt;/html&amp;gt;
  152. &lt;/code&gt;&lt;/pre&gt;
  153.  
  154.         </summary>
  155.     </entry>
  156.     <entry>
  157.         <id>http://stackoverflow.com/q/39584227</id>
  158.         <re:rank scheme="http://stackoverflow.com">7</re:rank>
  159.         <title type="text">in Laravel how to change the view content at runtime each time before compilation</title>
  160.             <category scheme="http://stackoverflow.com/tags" term="php" />
  161.             <category scheme="http://stackoverflow.com/tags" term="laravel" />
  162.             <category scheme="http://stackoverflow.com/tags" term="laravel-5" />
  163.             <category scheme="http://stackoverflow.com/tags" term="blade" />
  164.         <author>
  165.             <name>ahmed</name>
  166.             <uri>http://stackoverflow.com/users/459737</uri>
  167.         </author>
  168.         <link rel="alternate" href="http://stackoverflow.com/questions/39584227/in-laravel-how-to-change-the-view-content-at-runtime-each-time-before-compilatio" />
  169.         <published>2016-09-22T18:10:52Z</published>
  170.         <updated>2016-09-26T16:53:44Z</updated>
  171.         <summary type="html">
  172.            
  173.  
  174.             &lt;p&gt;in Laravel 5 I need to amend a view content at runtime before compilation by adding this string: &quot;@extends(foo)&quot; &lt;/p&gt;
  175.  
  176. &lt;p&gt;&lt;strong&gt;note&lt;/strong&gt;: changing the view &lt;strong&gt;&lt;em&gt;file&lt;/em&gt;&lt;/strong&gt; content is not an option&lt;/p&gt;
  177.  
  178. &lt;p&gt;so the process will be something like (each time a view is called)&lt;/p&gt;
  179.  
  180. &lt;ol&gt;
  181. &lt;li&gt;getting the view content &lt;/li&gt;
  182. &lt;li&gt;edit the view content by appending &quot;@extends(foo)&quot; keyword&lt;/li&gt;
  183. &lt;li&gt;compile (render) the view&lt;/li&gt;
  184. &lt;/ol&gt;
  185.  
  186. &lt;p&gt;I have tried using viewcomposer and middleware with no luck  &lt;/p&gt;
  187.  
  188. &lt;p&gt;&lt;strong&gt;here is my composer service provider:&lt;/strong&gt;
  189.    
  190.  
  191. &lt;pre&gt;&lt;code&gt;namespace App\Providers;
  192.  
  193. use Illuminate\Support\Facades\View;
  194. use Illuminate\Support\ServiceProvider;
  195.  
  196. class ComposerServiceProvider extends ServiceProvider
  197. {
  198.     public function boot()
  199.     {
  200.  
  201.         View::composer(&#39;pages/*&#39;, function ($view) {
  202.  
  203.              // i want to do the following:
  204.              // 1- find all view under directory resources/views/pages
  205.              // 2- then add the following blade command &quot;@extends(foo)&quot; at the beginning of the view before compile
  206.  
  207.         });
  208.  
  209.     }
  210.  
  211.  
  212.     public function register()
  213.     {
  214.         //
  215.     }
  216. }
  217. &lt;/code&gt;&lt;/pre&gt;
  218.  
  219. &lt;p&gt;&lt;strong&gt;and here is my view middleware try (in middleware i was able to amend view content after compilation :( )&lt;/strong&gt;&lt;/p&gt;
  220.  
  221. &lt;pre&gt;&lt;code&gt;&amp;lt;?php
  222. namespace App\Http\Middleware;
  223. use Closure;
  224. class ViewMiddleware
  225. {
  226.     public function handle($request, Closure $next)
  227.     {
  228.         $response =  $next($request);
  229.         if (!method_exists($response,&#39;content&#39;)) {
  230.             return $response;
  231.         }
  232.  
  233.         $content  = &quot;@extends(&#39;layouts.app&#39;)&quot;.$response-&amp;gt;content();
  234.         $response-&amp;gt;setContent($content);
  235.         return $response;
  236.     }
  237. }
  238. &lt;/code&gt;&lt;/pre&gt;
  239.  
  240. &lt;p&gt;Thanks&lt;/p&gt;
  241.  
  242. &lt;p&gt;&lt;strong&gt;Update&lt;/strong&gt;:
  243. what i need to accomplish is to extending views with layouts based on their parent directories&lt;/p&gt;
  244.  
  245. &lt;p&gt;for example my view directory have the following structure&lt;/p&gt;
  246.  
  247. &lt;p&gt;I need the view &quot;controlpanel.blade.php&quot; to have the layout &quot;layout/admin.blade.php&quot; because its parent folder is called &quot;admin&quot;&lt;/p&gt;
  248.  
  249. &lt;pre&gt;&lt;code&gt;-view
  250.   |--pages
  251.     |--admin
  252.       |--controlpanel.blade.php
  253.   |--layouts
  254.      |--admin.blade.php
  255. &lt;/code&gt;&lt;/pre&gt;
  256.  
  257.         </summary>
  258.     </entry>
  259.     <entry>
  260.         <id>http://stackoverflow.com/q/39604197</id>
  261.         <re:rank scheme="http://stackoverflow.com">1</re:rank>
  262.         <title type="text">How to Rewrite TimThumb to be used on emails</title>
  263.             <category scheme="http://stackoverflow.com/tags" term="php" />
  264.             <category scheme="http://stackoverflow.com/tags" term=".htaccess" />
  265.             <category scheme="http://stackoverflow.com/tags" term="mod-rewrite" />
  266.             <category scheme="http://stackoverflow.com/tags" term="timthumb" />
  267.         <author>
  268.             <name>SimonLeCat</name>
  269.             <uri>http://stackoverflow.com/users/4458531</uri>
  270.         </author>
  271.         <link rel="alternate" href="http://stackoverflow.com/questions/39604197/how-to-rewrite-timthumb-to-be-used-on-emails" />
  272.         <published>2016-09-22T22:15:33Z</published>
  273.         <updated>2016-09-28T00:30:53Z</updated>
  274.         <summary type="html">
  275.            
  276.  
  277.             &lt;p&gt;On my server I use TimThumb as plugin for resize my images, it works great except when I try to use it inside the content of my emails.&lt;/p&gt;
  278.  
  279. &lt;p&gt;Google Gmail output this &lt;code&gt;https://example.com/thumb.php?sr+c=&lt;/code&gt; as &lt;code&gt;src&lt;/code&gt; attribute (notice the plus sign).&lt;/p&gt;
  280.  
  281. &lt;p&gt;I read &lt;a href=&quot;http://stackoverflow.com/questions/20903967/gmails-new-image-caching-is-breaking-image-links-in-newsletter&quot;&gt;here&lt;/a&gt; that it&#39;s because of the query.&lt;/p&gt;
  282.  
  283. &lt;p&gt;So how can I use &lt;code&gt;.htaccess&lt;/code&gt; to rewrite my url and remove &lt;code&gt;/thumb.php?src=&lt;/code&gt; with a &lt;code&gt;/src/&lt;/code&gt;?&lt;/p&gt;
  284.  
  285. &lt;p&gt;This is how it looks a link to the image:&lt;/p&gt;
  286.  
  287. &lt;pre&gt;&lt;code&gt;https://example.com/thumb.php?src=example.jpg
  288. &lt;/code&gt;&lt;/pre&gt;
  289.  
  290. &lt;p&gt;This is what I need&lt;/p&gt;
  291.  
  292. &lt;pre&gt;&lt;code&gt;https://example.com/src/example.jpg
  293. &lt;/code&gt;&lt;/pre&gt;
  294.  
  295. &lt;p&gt;This is my current &lt;code&gt;.htaccess&lt;/code&gt;&lt;/p&gt;
  296.  
  297. &lt;pre&gt;&lt;code&gt;RewriteEngine On
  298. RewriteCond %{REQUEST_FILENAME} -f [OR]
  299. RewriteCond %{REQUEST_FILENAME} -d
  300. RewriteRule ^ - [L]
  301. RewriteRule ^welcome/([^/]+)/?$ index.php?a=welcome&amp;amp;filter=$1 [NC,QSA,L]
  302. RewriteRule ^explore/([^/]+)/?$         index.php?a=explore&amp;amp;filter=$1   [NC,QSA,L]
  303. RewriteRule ^page/([^/]+)/?$            index.php?a=page&amp;amp;filter=$1      [NC,QSA,L]
  304. RewriteRule ^(([^/]+)+)(/([^/]{0,32})(/.+)?)?$ index.php?a=$1&amp;amp;q=$3 [L,QSA]
  305. &lt;/code&gt;&lt;/pre&gt;
  306.  
  307. &lt;p&gt;&lt;code&gt;index.php&lt;/code&gt; and &lt;code&gt;thumb.php&lt;/code&gt; are both in the root folder&lt;/p&gt;
  308.  
  309. &lt;p&gt;&lt;strong&gt;UPDATE&lt;/strong&gt;&lt;/p&gt;
  310.  
  311. &lt;p&gt;I tried to add this line to my &lt;code&gt;.htaccess&lt;/code&gt; and visit &lt;code&gt;https://example.com/src/example.jpg&lt;/code&gt; but again it&#39;s not working, in this case it redirects to the &quot;welcome&quot; page.&lt;/p&gt;
  312.  
  313. &lt;pre&gt;&lt;code&gt;RewriteRule ^src/([^/]*)$ /thumb.php?src=$1 [L]
  314. &lt;/code&gt;&lt;/pre&gt;
  315.  
  316. &lt;p&gt;&lt;strong&gt;2nd UPDATE&lt;/strong&gt;&lt;/p&gt;
  317.  
  318. &lt;p&gt;I tried this too: &lt;/p&gt;
  319.  
  320. &lt;pre&gt;&lt;code&gt;RewriteRule ^src/([^/]+)/?$ thumb.php?src=$1 [NC,QSA,L]
  321. &lt;/code&gt;&lt;/pre&gt;
  322.  
  323. &lt;p&gt;Again it&#39;s not working &lt;code&gt;https://example.com/src/example.jpg&lt;/code&gt; redirects to my &quot;welcome&quot; page.&lt;/p&gt;
  324.  
  325. &lt;p&gt;This is how it looks now my .htaccess&lt;/p&gt;
  326.  
  327. &lt;pre&gt;&lt;code&gt;RewriteEngine On
  328. RewriteCond %{REQUEST_FILENAME} -f [OR]
  329. RewriteCond %{REQUEST_FILENAME} -d
  330. RewriteRule ^ - [L]
  331. RewriteRule ^welcome/([^/]+)/?$ index.php?a=welcome&amp;amp;filter=$1 [NC,QSA,L]
  332. RewriteRule ^explore/([^/]+)/?$         index.php?a=explore&amp;amp;filter=$1   [NC,QSA,L]
  333. RewriteRule ^page/([^/]+)/?$            index.php?a=page&amp;amp;filter=$1      [NC,QSA,L]
  334. RewriteRule ^src/([^/]+)/?$ thumb.php?src=$1 [NC,QSA,L]
  335. RewriteRule ^(([^/]+)+)(/([^/]{0,32})(/.+)?)?$ index.php?a=$1&amp;amp;q=$3 [L,QSA]
  336. &lt;/code&gt;&lt;/pre&gt;
  337.  
  338. &lt;p&gt;&lt;strong&gt;3rd UPDATE&lt;/strong&gt;&lt;/p&gt;
  339.  
  340. &lt;p&gt;Inside &lt;code&gt;thumb.php&lt;/code&gt; this is how I build up the src query&lt;/p&gt;
  341.  
  342. &lt;pre&gt;&lt;code&gt;$_GET[&#39;src&#39;] = &#39;https://s3-eu-west-1.amazonaws.com/bucket1&#39;.&#39;/&#39;.$_GET[&#39;src&#39;];
  343. &lt;/code&gt;&lt;/pre&gt;
  344.  
  345. &lt;p&gt;I can&#39;t figured it out what&#39;s wrong here.&lt;/p&gt;
  346.  
  347. &lt;p&gt;&lt;strong&gt;4th UPDATE&lt;/strong&gt;&lt;/p&gt;
  348.  
  349. &lt;p&gt;Based on Vladimir Cvetic answer I tried this:&lt;/p&gt;
  350.  
  351. &lt;pre&gt;&lt;code&gt;RewriteEngine On
  352. RewriteCond %{REQUEST_FILENAME} -f [OR]
  353. RewriteCond %{REQUEST_FILENAME} -d
  354. RewriteRule ^ - [L]
  355. RewriteRule ^src/(.*)$ /thumb.php?src=$1 [L,QSA]
  356. RewriteRule ^welcome/([^/]+)/?$ index.php?a=welcome&amp;amp;filter=$1 [NC,QSA,L]
  357. RewriteRule ^explore/([^/]+)/?$         index.php?a=explore&amp;amp;filter=$1   [NC,QSA,L]
  358. RewriteRule ^page/([^/]+)/?$            index.php?a=page&amp;amp;filter=$1      [NC,QSA,L]
  359. RewriteRule ^src/([^/]+)/?$ thumb.php?src=$1 [NC,QSA,L]
  360. RewriteRule ^(([^/]+)+)(/([^/]{0,32})(/.+)?)?$ index.php?a=$1&amp;amp;q=$3 [L,QSA]
  361. &lt;/code&gt;&lt;/pre&gt;
  362.  
  363. &lt;p&gt;And again it&#39;s not working, this is the error: &lt;/p&gt;
  364.  
  365. &lt;pre&gt;&lt;code&gt;`The &#39;t&#39; parameter is not set.`
  366. &lt;/code&gt;&lt;/pre&gt;
  367.  
  368. &lt;p&gt;But it&#39;s strange since I set the &#39;t&#39; parameter condition empty as below:&lt;/p&gt;
  369.  
  370. &lt;pre&gt;&lt;code&gt;if(!empty($_GET[&#39;t&#39;])) {
  371.     if($_GET[&#39;t&#39;] == &#39;a&#39;) {
  372.         $type = &#39;uploads/avatars&#39;;
  373.         $width_list = array(25, 35, 50, 70, 100, 112, 150, 200, 300);
  374.         $height_list = array(25, 35, 50, 70, 100, 112, 150, 200, 300);
  375.     } elseif($_GET[&#39;t&#39;] == &#39;b&#39;) {
  376.         $type = &#39;uploads/backgrounds&#39;;
  377.         ...
  378.     } else {
  379.         exit(&#39;Invalid parameter value&#39;);
  380.     }
  381. } else {
  382.     $_GET[&#39;t&#39;] == &#39;a&#39;;
  383.         $type = &#39;uploads/avatars&#39;;
  384.         $width_list = array(25, 35, 50, 70, 100, 112, 150, 200, 300);
  385.         $height_list = array(25, 35, 50, 70, 100, 112, 150, 200, 300);
  386. }
  387. &lt;/code&gt;&lt;/pre&gt;
  388.  
  389. &lt;p&gt;Indeed if I visit &lt;code&gt;https://example.com/thumb.php?src=example.jpg&lt;/code&gt; I can see the avatar image correctly&lt;/p&gt;
  390.  
  391.         </summary>
  392.     </entry>
  393.     <entry>
  394.         <id>http://stackoverflow.com/q/39617273</id>
  395.         <re:rank scheme="http://stackoverflow.com">4</re:rank>
  396.         <title type="text">Web Config file for a codeigniter application</title>
  397.             <category scheme="http://stackoverflow.com/tags" term="php" />
  398.             <category scheme="http://stackoverflow.com/tags" term="codeigniter" />
  399.             <category scheme="http://stackoverflow.com/tags" term="iis" />
  400.             <category scheme="http://stackoverflow.com/tags" term="web-config" />
  401.         <author>
  402.             <name>Dhaval Purohit</name>
  403.             <uri>http://stackoverflow.com/users/5449410</uri>
  404.         </author>
  405.         <link rel="alternate" href="http://stackoverflow.com/questions/39617273/web-config-file-for-a-codeigniter-application" />
  406.         <published>2016-09-24T06:41:13Z</published>
  407.         <updated>2016-09-28T15:49:53Z</updated>
  408.         <summary type="html">
  409.            
  410.  
  411.             &lt;p&gt;I am suffering with a web config file that is not rewrite the url for my codeigniter application. here is the web config file.&lt;/p&gt;
  412.  
  413. &lt;pre&gt;&lt;code&gt;&amp;lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&amp;gt;
  414. &amp;lt;configuration&amp;gt;
  415. &amp;lt;system.webServer&amp;gt;
  416.     &amp;lt;rewrite&amp;gt;
  417.         &amp;lt;rules&amp;gt;
  418.             &amp;lt;rule name=&quot;Clean URL&quot; stopProcessing=&quot;true&quot;&amp;gt;
  419.                 &amp;lt;match url=&quot;.*&quot; /&amp;gt;
  420.                 &amp;lt;conditions&amp;gt;
  421.                     &amp;lt;add input=&quot;{REQUEST_FILENAME}&quot; matchType=&quot;IsFile&quot; negate=&quot;true&quot; /&amp;gt;
  422.                     &amp;lt;add input=&quot;{REQUEST_FILENAME}&quot; matchType=&quot;IsDirectory&quot; negate=&quot;true&quot; /&amp;gt;
  423.                 &amp;lt;/conditions&amp;gt;
  424.                 &amp;lt;action type=&quot;Rewrite&quot; url=&quot;index.php?{R:1}&quot; appendQueryString=&quot;true&quot; /&amp;gt;
  425.             &amp;lt;/rule&amp;gt;
  426.         &amp;lt;/rules&amp;gt;
  427.     &amp;lt;/rewrite&amp;gt;
  428. &amp;lt;/system.webServer&amp;gt;
  429. &amp;lt;/configuration&amp;gt;
  430. &lt;/code&gt;&lt;/pre&gt;
  431.  
  432. &lt;p&gt;here is my site :
  433. &lt;a href=&quot;http://gandhitomodi.com&quot; rel=&quot;nofollow&quot;&gt;http://gandhitomodi.com&lt;/a&gt;&lt;/p&gt;
  434.  
  435. &lt;p&gt;i am not able to get this kind of url
  436. &lt;a href=&quot;http://gandhitomodi.com/controller/method/&quot; rel=&quot;nofollow&quot;&gt;http://gandhitomodi.com/controller/method/&lt;/a&gt;&lt;/p&gt;
  437.  
  438. &lt;p&gt;for example&lt;/p&gt;
  439.  
  440. &lt;p&gt;&lt;a href=&quot;http://gandhitomodi.com/welcome/index/&quot; rel=&quot;nofollow&quot;&gt;http://gandhitomodi.com/welcome/index/&lt;/a&gt;&lt;/p&gt;
  441.  
  442. &lt;p&gt;Please Help me through this.&lt;/p&gt;
  443.  
  444. &lt;p&gt;****Edited*****&lt;/p&gt;
  445.  
  446. &lt;p&gt;here is the route.php&lt;/p&gt;
  447.  
  448. &lt;pre&gt;&lt;code&gt;$route[&#39;default_controller&#39;]=&quot;welcome/index&quot;;
  449. $route[&#39;sendmail&#39;]=&quot;welcome/send&quot;;
  450. &lt;/code&gt;&lt;/pre&gt;
  451.  
  452. &lt;p&gt;here is the config.php settings that i have changed.&lt;/p&gt;
  453.  
  454. &lt;pre&gt;&lt;code&gt;$config[&#39;base_url&#39;]=&quot;http://gandhitomodi.com/&quot;;
  455. $config[&#39;index_page&#39;]=&#39;&#39;;
  456. $config[&#39;url_protocal&#39;]=&#39;PATH_INFO&#39;;`
  457. &lt;/code&gt;&lt;/pre&gt;
  458.  
  459.         </summary>
  460.     </entry>
  461.     <entry>
  462.         <id>http://stackoverflow.com/q/39618487</id>
  463.         <re:rank scheme="http://stackoverflow.com">0</re:rank>
  464.         <title type="text">How to get Google Adwords ad cost over time with PHP?</title>
  465.             <category scheme="http://stackoverflow.com/tags" term="php" />
  466.             <category scheme="http://stackoverflow.com/tags" term="google-adwords" />
  467.         <author>
  468.             <name>Alan</name>
  469.             <uri>http://stackoverflow.com/users/6200144</uri>
  470.         </author>
  471.         <link rel="alternate" href="http://stackoverflow.com/questions/39618487/how-to-get-google-adwords-ad-cost-over-time-with-php" />
  472.         <published>2016-09-25T09:14:01Z</published>
  473.         <updated>2016-09-25T09:14:01Z</updated>
  474.         <summary type="html">
  475.            
  476.  
  477.             &lt;p&gt;So I have successfully established an ouath connection with Google Adwords, but I fail to realize how a request should look like in order to get the ad cost over time. What parameters should I use?
  478. I was hoping to find a more simple solution, like the api calls made to Google Analytics:&lt;/p&gt;
  479.  
  480. &lt;pre&gt;&lt;code&gt;   public function getAudienceMetricsAll($google_analytics_account_id)
  481.     {
  482.         $curl = new Curl(&quot;https://www.googleapis.com/analytics/v3/data/ga&quot;);
  483.         $curl-&amp;gt;setParams([
  484.             &quot;ids&quot;         =&amp;gt; &quot;ga:&quot; . $google_analytics_account_id,
  485.             &quot;dimensions&quot;  =&amp;gt; &quot;ga:date&quot;,
  486.             &quot;metrics&quot;     =&amp;gt; &quot;ga:users,ga:newUsers,ga:percentNewSessions,ga:sessions,ga:bounces,ga:bounceRate,ga:avgSessionDuration,ga:goalStartsAll,ga:pageviews,ga:pageViewsPerSession&quot;,
  487.             &quot;start-date&quot;  =&amp;gt; &quot;730daysAgo&quot;,
  488.             &quot;end-date&quot;    =&amp;gt; &quot;today&quot;,
  489.             &quot;max-results&quot; =&amp;gt; 10000
  490.         ]);
  491.         $curl-&amp;gt;setHeaders([
  492.             &quot;Authorization&quot; =&amp;gt; &quot;Bearer &quot; . @$this-&amp;gt;aim_account-&amp;gt;settings[&quot;credentials&quot;][&quot;access_token&quot;]
  493.         ]);
  494.  
  495.         $data = $curl-&amp;gt;sendRequest(&quot;json&quot;);
  496.  
  497.         return $data;
  498.     }
  499. &lt;/code&gt;&lt;/pre&gt;
  500.  
  501. &lt;p&gt;I mean, just the url and params I need to send in the body of the request. But I don&#39;t seem to be able to find such information.&lt;/p&gt;
  502.  
  503. &lt;p&gt;Thank you for your time! Any help is welcomed!&lt;/p&gt;
  504.  
  505.         </summary>
  506.     </entry>
  507.     <entry>
  508.         <id>http://stackoverflow.com/q/26163465</id>
  509.         <re:rank scheme="http://stackoverflow.com">5</re:rank>
  510.         <title type="text">Error 502 in php-fpm without any details</title>
  511.             <category scheme="http://stackoverflow.com/tags" term="php" />
  512.             <category scheme="http://stackoverflow.com/tags" term="nginx" />
  513.         <author>
  514.             <name>Christian</name>
  515.             <uri>http://stackoverflow.com/users/935122</uri>
  516.         </author>
  517.         <link rel="alternate" href="http://stackoverflow.com/questions/26163465/error-502-in-php-fpm-without-any-details" />
  518.         <published>2016-09-25T13:05:55Z</published>
  519.         <updated>2016-09-28T14:14:17Z</updated>
  520.         <summary type="html">
  521.            
  522.  
  523.             &lt;p&gt;I am beginning to despise PHP-FPM! it&#39;s horrendous at handling errors!&lt;/p&gt;
  524.  
  525. &lt;p&gt;I am getting a &lt;code&gt;NetworkError: 502 Bad Gateway&lt;/code&gt; and although I know where the error is occurring because i manually un-commented line by line until i found the bad line, i don&#39;t know why that line is causing a problem.&lt;/p&gt;
  526.  
  527. &lt;p&gt;Before you ask what the line is that is causing the error, that isn&#39;t my problem, my problem is that I can&#39;t get PHP to tell me what the error is. It just keeps responding with a 502 error.&lt;/p&gt;
  528.  
  529. &lt;p&gt;Here is my configuration&lt;/p&gt;
  530.  
  531. &lt;p&gt;nginx site&lt;/p&gt;
  532.  
  533. &lt;pre&gt;&lt;code&gt;location ~ .+?\.php {
  534.     fastcgi_split_path_info ^(.+?\.php)/?(.*)$;
  535.     if (!-f $document_root$fastcgi_script_name) {
  536.         return 404;
  537.     }
  538.     include fastcgi_params;
  539.     fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
  540.     fastcgi_param PATH_INFO $fastcgi_path_info;
  541.     fastcgi_param LOG_PATH /var/www/sites/api/logs;
  542.     fastcgi_param ENVIRONMENT dev;
  543.     fastcgi_buffer_size 128k;
  544.     fastcgi_buffers 254 16k;
  545.     fastcgi_busy_buffers_size 256k;
  546.     fastcgi_temp_file_write_size 256k;
  547.     proxy_intercept_errors on;
  548.     fastcgi_intercept_errors on;
  549.     fastcgi_pass unix:/var/run/php5-fpm.sock;
  550.     fastcgi_index index.php;
  551. }
  552. &lt;/code&gt;&lt;/pre&gt;
  553.  
  554. &lt;p&gt;php.ini&lt;/p&gt;
  555.  
  556. &lt;pre&gt;&lt;code&gt;[PHP]
  557. engine = On
  558. expose_php = Off
  559. max_execution_time = 30
  560. memory_limit = 128M
  561. default_socket_timeout = 5
  562. session.save_path = /var/www/session/
  563. file_uploads = Off
  564. upload_tmp_dir = /tmp/php
  565. upload_max_filesize = 5M
  566. post_max_size = 5M
  567. max_file_uploads = 1
  568. date.timezone = &#39;UTC&#39;
  569. disable_functions = phpinfo,exec,passthru,shell_exec,system,proc_open,popen,curl_multi_exec,parse_ini_file,show_source
  570. mail.add_x_header = Off
  571. sql.safe_mode = On
  572. cgi.force_redirect = 1
  573. allow_url_fopen = Off
  574. allow_url_include = Off
  575.  
  576. error_reporting = E_ALL
  577. display_errors = On
  578. display_startup_errors = On
  579. html_errors = Off
  580. log_errors = On
  581. error_log = /var/log/php5-fpm.log
  582. log_errors_max_len = 1024
  583. ignore_repeated_errors = Off
  584. ignore_repeated_source = Off
  585. report_memleaks = On
  586. track_errors = On
  587. &lt;/code&gt;&lt;/pre&gt;
  588.  
  589. &lt;p&gt;pool.d/www.conf&lt;/p&gt;
  590.  
  591. &lt;pre&gt;&lt;code&gt;[www]
  592. listen = /var/run/php5-fpm.sock
  593. user = www-data
  594. group = www-data
  595. listen.owner = www-data
  596. listen.group = www-data
  597.  
  598. pm = static
  599. pm.max_children = 600
  600. ;pm.start_servers = 10
  601. ;pm.min_spare_servers = 5
  602. ;pm.max_spare_servers = 15
  603. pm.max_requests = 100
  604. ;pm.status_path = /php_status
  605.  
  606. ;request_terminate_timeout = 5s
  607. ;request_slowlog_timeout = 5s
  608. ;slowlog = /var/log/php/fpm/domain.slowlog.log
  609.  
  610. ; Redirect worker stdout and stderr into main error log. If not set, stdout and
  611. ; stderr will be redirected to /dev/null according to FastCGI specs.
  612. ; Default Value: no
  613. catch_workers_output = yes
  614.  
  615. php_flag[display_errors] = on
  616. php_flag[display_startup_errors] = on
  617. ;php_flag[output_buffering] = off
  618.  
  619. php_admin_value[error_log] = /var/log/php5-fpm.log
  620. php_admin_flag[log_errors] = on
  621. &lt;/code&gt;&lt;/pre&gt;
  622.  
  623. &lt;p&gt;and all i get in the logs is the following&lt;/p&gt;
  624.  
  625. &lt;p&gt;site error log&lt;/p&gt;
  626.  
  627. &lt;pre&gt;&lt;code&gt;2014/10/02 14:34:50 [error] 25966#0: *9 recv() failed (104: Connection reset by peer) while reading response header from upstream, client: 109.70.40.213, server: www.example.com, request: &quot;POST /v2/payments/payment/sale HTTP/1.1&quot;, upstream: &quot;fastcgi://unix:/var/run/php5-fpm.sock:&quot;, host: &quot;www.example.cm&quot;, referrer: &quot;http://boxshop.im/checkout&quot;
  628. &lt;/code&gt;&lt;/pre&gt;
  629.  
  630. &lt;p&gt;php error log&lt;/p&gt;
  631.  
  632. &lt;pre&gt;&lt;code&gt;[02-Oct-2014 14:44:26.023450] DEBUG: pid 25216, fpm_event_loop(), line 419: event module triggered 2 events
  633. [02-Oct-2014 14:44:26.023927] DEBUG: pid 25216, fpm_got_signal(), line 76: received SIGCHLD
  634. [02-Oct-2014 14:44:26.024044] WARNING: pid 25216, fpm_children_bury(), line 252: [pool www] child 25251 exited on signal 11 (SIGSEGV) after 1441.610042 seconds from start
  635. [02-Oct-2014 14:44:26.025943] NOTICE: pid 25216, fpm_children_make(), line 421: [pool www] child 26039 started
  636. [02-Oct-2014 14:44:26.026192] DEBUG: pid 25216, fpm_event_loop(), line 419: event module triggered 1 events
  637. &lt;/code&gt;&lt;/pre&gt;
  638.  
  639. &lt;p&gt;a nice, &lt;code&gt;Parse Error on line 234&lt;/code&gt; would be nice!&lt;/p&gt;
  640.  
  641. &lt;h1&gt;frustrated&lt;/h1&gt;
  642.  
  643.         </summary>
  644.     </entry>
  645.     <entry>
  646.         <id>http://stackoverflow.com/q/39669654</id>
  647.         <re:rank scheme="http://stackoverflow.com">0</re:rank>
  648.         <title type="text">Trello API: get members, attachments, and card information in one call?</title>
  649.             <category scheme="http://stackoverflow.com/tags" term="php" />
  650.             <category scheme="http://stackoverflow.com/tags" term="trello" />
  651.         <author>
  652.             <name>Matthew Johnson</name>
  653.             <uri>http://stackoverflow.com/users/1639566</uri>
  654.         </author>
  655.         <link rel="alternate" href="http://stackoverflow.com/questions/39669654/trello-api-get-members-attachments-and-card-information-in-one-call" />
  656.         <published>2016-09-26T04:26:49Z</published>
  657.         <updated>2016-09-27T02:29:28Z</updated>
  658.         <summary type="html">
  659.            
  660.  
  661.             &lt;p&gt;I can get data from the Trello API using this:&lt;/p&gt;
  662.  
  663. &lt;pre&gt;&lt;code&gt;private function get_card_info($card_id) {
  664.     $client =         new \GuzzleHttp\Client();
  665.     $base =           $this-&amp;gt;endpoint . $card_id;
  666.     $params =         &quot;?key=&quot; . $this-&amp;gt;api_key . &quot;&amp;amp;token=&quot; . $this-&amp;gt;token;      
  667.     $cardURL =        $base . $params;
  668.     $membersURL =     $base . &quot;/members&quot; . $params;
  669.     $attachmentsURL = $base . &quot;/attachments&quot; . $params;
  670.  
  671.     $response = $client-&amp;gt;get($cardURL);
  672.     $this-&amp;gt;card_info[&#39;card&#39;] = json_decode($response-&amp;gt;getBody()-&amp;gt;getContents());
  673.  
  674.     $response = $client-&amp;gt;get($membersURL);
  675.     $this-&amp;gt;card_info[&#39;members&#39;] = json_decode($response-&amp;gt;getBody()-&amp;gt;getContents());
  676.  
  677.     $response = $client-&amp;gt;get($attachmentsURL);      
  678.     $this-&amp;gt;card_info[&#39;attachments&#39;] = json_decode($response-&amp;gt;getBody()-&amp;gt;getContents());
  679. }
  680. &lt;/code&gt;&lt;/pre&gt;
  681.  
  682. &lt;p&gt;However, this is broken into three calls.  Is there a way to get card information, the member information, and the attachment information all in one call?  The &lt;a href=&quot;https://developers.trello.com/advanced-reference/card&quot; rel=&quot;nofollow&quot;&gt;docs&lt;/a&gt; mention using &lt;code&gt;&amp;amp;fields=name,id&lt;/code&gt;, but that only seems to limit what&#39;s returned from the base call to the &lt;code&gt;cards&lt;/code&gt; endpoint.&lt;/p&gt;
  683.  
  684. &lt;p&gt;It&#39;s absurd to have to hit the API 3 times every time I need card information, but I can&#39;t find any examples gathering all that&#39;s needed.&lt;/p&gt;
  685.  
  686.         </summary>
  687.     </entry>
  688.     <entry>
  689.         <id>http://stackoverflow.com/q/39634178</id>
  690.         <re:rank scheme="http://stackoverflow.com">8</re:rank>
  691.         <title type="text">Laravel Multi Insert issue with quotes in value</title>
  692.             <category scheme="http://stackoverflow.com/tags" term="php" />
  693.             <category scheme="http://stackoverflow.com/tags" term="laravel" />
  694.             <category scheme="http://stackoverflow.com/tags" term="eloquent" />
  695.             <category scheme="http://stackoverflow.com/tags" term="laravel-5.2" />
  696.         <author>
  697.             <name>Awais Qarni</name>
  698.             <uri>http://stackoverflow.com/users/526367</uri>
  699.         </author>
  700.         <link rel="alternate" href="http://stackoverflow.com/questions/39634178/laravel-multi-insert-issue-with-quotes-in-value" />
  701.         <published>2016-09-26T07:07:22Z</published>
  702.         <updated>2016-09-29T05:21:54Z</updated>
  703.         <summary type="html">
  704.            
  705.  
  706.             &lt;p&gt;I need t insert a large set of records in database. I am getting data from a csv then I need to insert in database. I thought to do it using multi insert statement for good performance. So I did like following:&lt;/p&gt;
  707.  
  708. &lt;pre&gt;&lt;code&gt; foreach($data as $key =&amp;gt; $value) {
  709.  
  710.    $insert[] = [
  711.                 &#39;id&#39; =&amp;gt; $value-&amp;gt;id, &#39;is_published&#39; =&amp;gt; $value-&amp;gt;is_published,
  712.                 &quot;first_name&quot; =&amp;gt; $value-&amp;gt;first_name, &quot;middle_name&quot; =&amp;gt; $value-&amp;gt;middle_name, &quot;last_name&quot; =&amp;gt; $value-&amp;gt;last_name,
  713.                 &quot;description&quot; =&amp;gt; $value-&amp;gt;description,
  714.                 &quot;created_at&quot; =&amp;gt; date(&quot;Y-m-d H:i:s&quot;,strtotime($value-&amp;gt;created_at)),
  715.                 &quot;updated_at&quot; =&amp;gt; date(&quot;Y-m-d H:i:s&quot;,strtotime($value-&amp;gt;changed_at))
  716.             ];
  717.  }
  718.  
  719.  if(!empty($insert)){
  720.      Model::insert($insert);
  721.  }
  722. &lt;/code&gt;&lt;/pre&gt;
  723.  
  724. &lt;p&gt;By doing show I always get &lt;code&gt;mysql server gone away error&lt;/code&gt;. I have debugged it by printing query and I observed that by doing so, Laravel doesn&#39;t take care of single quotes, double quotes in description column as it automatically does while doing &lt;code&gt;$model::save();&lt;/code&gt; way. The printed query version breaks if description column have single quote &lt;code&gt;&#39;&lt;/code&gt; or double quote in it. &lt;/p&gt;
  725.  
  726. &lt;p&gt;But if I do some thing like&lt;/p&gt;
  727.  
  728. &lt;pre&gt;&lt;code&gt;foreach($data as $key=&amp;gt;$value){
  729.    $model = new Model();
  730.    $model-&amp;gt;id = $value-&amp;gt;id;
  731.    $model-&amp;gt;description = $value-&amp;gt;description;
  732.    blah blah bla
  733.  
  734.    $model-&amp;gt;save();
  735. }
  736. &lt;/code&gt;&lt;/pre&gt;
  737.  
  738. &lt;p&gt;It runs successfully without generating any error. Can any body let me know how to cater this problem?&lt;/p&gt;
  739.  
  740.         </summary>
  741.     </entry>
  742.     <entry>
  743.         <id>http://stackoverflow.com/q/39670758</id>
  744.         <re:rank scheme="http://stackoverflow.com">2</re:rank>
  745.         <title type="text">loading phpbb in laravel code conflicts</title>
  746.             <category scheme="http://stackoverflow.com/tags" term="php" />
  747.             <category scheme="http://stackoverflow.com/tags" term="laravel" />
  748.             <category scheme="http://stackoverflow.com/tags" term="laravel-5" />
  749.             <category scheme="http://stackoverflow.com/tags" term="composer-php" />
  750.             <category scheme="http://stackoverflow.com/tags" term="phpbb3" />
  751.         <author>
  752.             <name>JaChNo</name>
  753.             <uri>http://stackoverflow.com/users/621056</uri>
  754.         </author>
  755.         <link rel="alternate" href="http://stackoverflow.com/questions/39670758/loading-phpbb-in-laravel-code-conflicts" />
  756.         <published>2016-09-26T07:48:30Z</published>
  757.         <updated>2016-09-26T14:40:03Z</updated>
  758.         <summary type="html">
  759.            
  760.  
  761.             &lt;p&gt;I am trying to access some of the functions within PHPBB from my laravel application, this is for actions such as adding a user when a registration happens on my main site and autologins.&lt;/p&gt;
  762.  
  763. &lt;p&gt;Phpbb is installed under /public/forums and i have updated .htaccess to allow it. I am able to access and use it just fine.&lt;/p&gt;
  764.  
  765. &lt;p&gt;I have a helper that was originally constructed for codeigniter but should translate in to the laravel world. I am loading it as a helper by putting it under app, loading it using&lt;/p&gt;
  766.  
  767. &lt;pre&gt;&lt;code&gt;use App\Helpers\phpBBHelper;
  768. &lt;/code&gt;&lt;/pre&gt;
  769.  
  770. &lt;p&gt;and I access the functions as such&lt;/p&gt;
  771.  
  772. &lt;pre&gt;&lt;code&gt;   $ph = new phpBBHelper();
  773.    $ph-&amp;gt;addPhpbb3User(&#39;dave&#39;,&#39;password&#39;,&#39;dave@dave.com&#39;);
  774. &lt;/code&gt;&lt;/pre&gt;
  775.  
  776. &lt;p&gt;At the top of my helper I have this Construct&lt;/p&gt;
  777.  
  778. &lt;pre&gt;&lt;code&gt;public function __construct() {
  779.  
  780. // Set the variables scope
  781.         global $phpbb_root_path, $phpEx, $cache, $user, $db, $config, $template, $table_prefix;
  782.  
  783.         define(&#39;IN_PHPBB&#39;, TRUE);
  784.         define(&#39;FORUM_ROOT_PATH&#39;, &#39;forum/&#39;);
  785.  
  786.         $phpbb_root_path = (defined(&#39;PHPBB_ROOT_PATH&#39;)) ? PHPBB_ROOT_PATH :     FORUM_ROOT_PATH;
  787.         $phpEx = substr(strrchr(__FILE__, &#39;.&#39;), 1);
  788.         // Include needed files
  789.         include($phpbb_root_path . &#39;common.&#39; . $phpEx);
  790.  
  791.         // Initialize phpBB user session
  792.         $user-&amp;gt;session_begin();
  793.         $auth-&amp;gt;acl($user-&amp;gt;data);
  794.         $user-&amp;gt;setup();
  795.  
  796.         // Save user data into $_user variable
  797.         $this-&amp;gt;_user = $user;  
  798.     }
  799. &lt;/code&gt;&lt;/pre&gt;
  800.  
  801. &lt;p&gt;When i execute the code I get a server 500 error&lt;/p&gt;
  802.  
  803. &lt;p&gt;PHP Fatal error:  Call to a member function getScriptName() on null in /home/ubuntu/workspace/public/forum/phpbb/session.php on line 50&lt;/p&gt;
  804.  
  805. &lt;p&gt;which is this line &lt;/p&gt;
  806.  
  807. &lt;pre&gt;&lt;code&gt;$script_name = $request-&amp;gt;escape($symfony_request-&amp;gt;getScriptName(), true);
  808. &lt;/code&gt;&lt;/pre&gt;
  809.  
  810. &lt;p&gt;I have found a post on stack overflow that exactly refers to my issue but the resolution of that issue was never posted&lt;/p&gt;
  811.  
  812. &lt;p&gt;&lt;a href=&quot;http://stackoverflow.com/questions/33905046/laravel-conflicting&quot; title=&quot;Laravel Conflicting&quot;&gt;http://stackoverflow.com/questions/33905046/laravel-conflicting&lt;/a&gt;&lt;/p&gt;
  813.  
  814. &lt;p&gt;In that thread it was suggested that because both PHP and Laravel both use composer it was causing a conflict when loading the classes. I am not sure if that is true. &lt;/p&gt;
  815.  
  816. &lt;p&gt;But Laravel is certainly affecting PHPBB when I call the $user-&gt;session_begin();&lt;/p&gt;
  817.  
  818.         </summary>
  819.     </entry>
  820.     <entry>
  821.         <id>http://stackoverflow.com/q/39674288</id>
  822.         <re:rank scheme="http://stackoverflow.com">6</re:rank>
  823.         <title type="text">Angular HTML5 mode, router going to otherwise state on page reload</title>
  824.             <category scheme="http://stackoverflow.com/tags" term="php" />
  825.             <category scheme="http://stackoverflow.com/tags" term="angularjs" />
  826.             <category scheme="http://stackoverflow.com/tags" term=".htaccess" />
  827.         <author>
  828.             <name>Chetan</name>
  829.             <uri>http://stackoverflow.com/users/2882437</uri>
  830.         </author>
  831.         <link rel="alternate" href="http://stackoverflow.com/questions/39674288/angular-html5-mode-router-going-to-otherwise-state-on-page-reload" />
  832.         <published>2016-09-26T08:41:01Z</published>
  833.         <updated>2016-09-28T04:15:06Z</updated>
  834.         <summary type="html">
  835.            
  836.  
  837.             &lt;p&gt;I am trying to remove hash tag from my website. I have achieved it by following code.&lt;/p&gt;
  838.  
  839. &lt;pre&gt;&lt;code&gt;$locationProvider.html5Mode(true);
  840. &lt;/code&gt;&lt;/pre&gt;
  841.  
  842. &lt;p&gt;As well as added base URL in index file as well.&lt;/p&gt;
  843.  
  844. &lt;p&gt;My issue is if i am on contct-us state after reloading entire page. i am redirecting to home state which is defined as otherwise state.&lt;/p&gt;
  845.  
  846. &lt;p&gt;Configuration used are - &lt;/p&gt;
  847.  
  848. &lt;p&gt;server -Appache
  849.   database - mysql&lt;/p&gt;
  850.  
  851. &lt;p&gt;I have added following code in .htaccess for rewriting rule as well -&lt;/p&gt;
  852.  
  853. &lt;pre&gt;&lt;code&gt;     RewriteEngine On
  854.      php_value post_max_size 120M
  855.     php_value upload_max_filesize 120M
  856.      php_value max_execution_time 90
  857.  
  858.  
  859.  
  860.      RewriteCond %{HTTP_HOST} ^54\.201\.153\.244$ [NC,OR]
  861.  
  862.      RewriteCond %{HTTPS} off
  863.      RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R,L]
  864.  
  865.       RewriteCond %{HTTP_HOST} ^adkarlo.com$ [NC]
  866.         RewriteRule ^(.*)$ https://www.adkarlo.com/$1 [R=301,L]
  867.  
  868.       #RewriteBase /html/
  869.       ErrorDocument 404 /404.php
  870.  
  871.     RewriteCond %{REQUEST_FILENAME} -f
  872.      RewriteRule ^ - [L]
  873.    RewriteRule ^(.*)$ index.php?/ [L]
  874. &lt;/code&gt;&lt;/pre&gt;
  875.  
  876. &lt;p&gt;Expected result - After reloading from state contact-us any page i want to go to same page.&lt;/p&gt;
  877.  
  878.         </summary>
  879.     </entry>
  880.     <entry>
  881.         <id>http://stackoverflow.com/q/39662492</id>
  882.         <re:rank scheme="http://stackoverflow.com">-1</re:rank>
  883.         <title type="text">PHP query not working with variable</title>
  884.             <category scheme="http://stackoverflow.com/tags" term="php" />
  885.             <category scheme="http://stackoverflow.com/tags" term="mysql" />
  886.         <author>
  887.             <name>Divyesh Jesadiya</name>
  888.             <uri>http://stackoverflow.com/users/4710899</uri>
  889.         </author>
  890.         <link rel="alternate" href="http://stackoverflow.com/questions/39662492/php-query-not-working-with-variable" />
  891.         <published>2016-09-26T11:32:16Z</published>
  892.         <updated>2016-09-29T05:18:14Z</updated>
  893.         <summary type="html">
  894.            
  895.  
  896.             &lt;p&gt;In my page I have this code with echo&#39;s.&lt;/p&gt;
  897.  
  898. &lt;pre&gt;&lt;code&gt;&amp;lt;?php
  899.  
  900. include(&quot;../config.php&quot;);
  901.  
  902. $q = mysql_query(&quot;SELECT propertyaddress FROM propertydetail WHERE active=&#39;yes&#39; and leasedatefrom=&#39;&quot;.date(&quot;m-d-Y&quot;, strtotime(&#39;+1 months&#39;)).&quot;&#39;&quot;);
  903. $res = mysql_fetch_array($q);
  904. echo &quot;&amp;lt;br/&amp;gt;pdetail=&quot;.$pdetail=trim($res[&#39;propertyaddress&#39;]);
  905. echo $query=&quot;SELECT * FROM tenantmaster WHERE propertyaddress like &#39;&quot;.$pdetail.&quot;&#39;&quot;;
  906. //echo $query=&quot;SELECT * FROM tenantmaster &quot;;
  907. //echo $query=&quot;SELECT * FROM tenantmaster WHERE propertyaddress = &#39;1934 Heron Ave Unit D Schaumburg IL 60193&#39;&quot;;
  908.  
  909. $resultdb = mysql_query($query);
  910. if (!$resultdb) {
  911.     die(&#39;Invalid query: &#39; . mysql_error());
  912. }
  913. else{
  914.     echo &quot;&amp;lt;br/&amp;gt;right query&quot;;
  915. }
  916.  
  917. echo &quot;&amp;lt;br/&amp;gt;num of row===&quot;.mysql_num_rows($resultdb);
  918. $rowt = mysql_fetch_array($resultdb);
  919. echo &quot;&amp;lt;br/&amp;gt;row===&quot;.$rowt[&#39;name&#39;];
  920. exit;
  921.  
  922. ?&amp;gt;
  923. &lt;/code&gt;&lt;/pre&gt;
  924.  
  925. &lt;blockquote&gt;
  926.   &lt;p&gt;config.php&lt;/p&gt;
  927. &lt;/blockquote&gt;
  928.  
  929. &lt;pre&gt;&lt;code&gt;&amp;lt;?php
  930.  
  931. $mysql_hostname = &quot;localhost&quot;;
  932. $mysql_user = &quot;root&quot;;
  933. $mysql_password = &quot;&quot;;
  934. $mysql_database = &quot;gms_estate&quot;;
  935.  
  936. /*
  937. $mysql_hostname = &quot;localhost&quot;;
  938. $mysql_user = &quot;root&quot;;
  939. $mysql_password = &quot;&quot;;
  940. $mysql_database = &quot;gms_estate&quot;;
  941. */
  942.  
  943. $bd = mysql_connect($mysql_hostname, $mysql_user, $mysql_password)
  944. or die(&quot;Opps some thing went wrong&quot;);
  945. mysql_select_db($mysql_database, $bd) or die(&quot;Opps some thing went wrong&quot;);
  946.  
  947. ?&amp;gt;
  948. &lt;/code&gt;&lt;/pre&gt;
  949.  
  950. &lt;p&gt;And problem is my first query &lt;code&gt;$q&lt;/code&gt; is working but query &lt;code&gt;$query&lt;/code&gt; is also working but &lt;code&gt;mysql_num_rows($resultdb)&lt;/code&gt; is not working and display &lt;code&gt;0&lt;/code&gt; rows but, when I run echo query to database it&#39;s displaying &lt;code&gt;1&lt;/code&gt; row. Why?&lt;/p&gt;
  951.  
  952. &lt;p&gt;I tried &lt;code&gt;$res[&#39;propertyaddress&#39;]&lt;/code&gt; variable with &lt;code&gt;trim()&lt;/code&gt; but not any success.&lt;/p&gt;
  953.  
  954. &lt;p&gt;But when I use &lt;strong&gt;1934 Heron Ave Unit D Schaumburg IL 60193&lt;/strong&gt; (that&#39;s my variable value) instead of &lt;code&gt;$res[&#39;propertyaddress&#39;]&lt;/code&gt; then it&#39;s working.&lt;/p&gt;
  955.  
  956. &lt;p&gt;So, when I give value of variable directly then it&#39;s working but when I give variable then not. Why?&lt;/p&gt;
  957.  
  958.         </summary>
  959.     </entry>
  960.     <entry>
  961.         <id>http://stackoverflow.com/q/39603501</id>
  962.         <re:rank scheme="http://stackoverflow.com">2</re:rank>
  963.         <title type="text">PHP function to return data from database as table with table relationships</title>
  964.             <category scheme="http://stackoverflow.com/tags" term="php" />
  965.             <category scheme="http://stackoverflow.com/tags" term="mysql" />
  966.             <category scheme="http://stackoverflow.com/tags" term="database" />
  967.             <category scheme="http://stackoverflow.com/tags" term="dynamic-programming" />
  968.         <author>
  969.             <name>sheldor73</name>
  970.             <uri>http://stackoverflow.com/users/3494103</uri>
  971.         </author>
  972.         <link rel="alternate" href="http://stackoverflow.com/questions/39603501/php-function-to-return-data-from-database-as-table-with-table-relationships" />
  973.         <published>2016-09-26T14:02:51Z</published>
  974.         <updated>2016-09-27T13:32:52Z</updated>
  975.         <summary type="html">
  976.            
  977.  
  978.             &lt;p&gt;I have a requirement for a PHP function that takes table or tables and the required columns from those db tables and returns a html table containing the data. I know how to do this for one table but am struggling with how to make this more dynamic&lt;/p&gt;
  979.  
  980. &lt;p&gt;My thinking for one table would be to have a function that takes the table name and then an array of columns and then just selects the data from the table and then loops through it constructing the data as html and then return that from the function.&lt;/p&gt;
  981.  
  982. &lt;p&gt;As an example my database has two tables; users and orders&lt;/p&gt;
  983.  
  984. &lt;pre&gt;&lt;code&gt;users
  985. |----------------------------|
  986. |user_id|first_name|last_name|
  987. |-------|----------|---------|
  988.  
  989. orders
  990. |----------------------|
  991. |order_id|user_id|total|
  992. |--------|-------|-----|
  993. &lt;/code&gt;&lt;/pre&gt;
  994.  
  995. &lt;p&gt;Now with the function discussed above it would be easy to generate a table for all the users or orders but what I would like to do is have a function where I could dynamically join tables and &lt;em&gt;for example&lt;/em&gt; list all users and the number of orders they&#39;ve made or list all orders from user x. I know that this would be possible with many different functions but I&#39;m really interested in developing a way of doing this dynamically and basically building all the relationships &lt;em&gt;somehow&lt;/em&gt; in the program and then be able to call one function and request columns x,y and z&lt;/p&gt;
  996.  
  997. &lt;p&gt;My thinking so far would be (again for this example) somehow define that &lt;code&gt;number of orders for user i = count(order_id) where user_id = i&lt;/code&gt;&lt;/p&gt;
  998.  
  999. &lt;p&gt;Hope this makes sense and thank you in advance&lt;/p&gt;
  1000.  
  1001.         </summary>
  1002.     </entry>
  1003.     <entry>
  1004.         <id>http://stackoverflow.com/q/39642322</id>
  1005.         <re:rank scheme="http://stackoverflow.com">-6</re:rank>
  1006.         <title type="text">What can delay &quot;Time to First byte&quot; by almost 2s?</title>
  1007.             <category scheme="http://stackoverflow.com/tags" term="php" />
  1008.             <category scheme="http://stackoverflow.com/tags" term="magento" />
  1009.             <category scheme="http://stackoverflow.com/tags" term="server-response" />
  1010.         <author>
  1011.             <name>surfer190</name>
  1012.             <uri>http://stackoverflow.com/users/2118666</uri>
  1013.         </author>
  1014.         <link rel="alternate" href="http://stackoverflow.com/questions/39642322/what-can-delay-time-to-first-byte-by-almost-2s" />
  1015.         <published>2016-09-26T14:50:01Z</published>
  1016.         <updated>2016-09-28T10:51:24Z</updated>
  1017.         <summary type="html">
  1018.            
  1019.  
  1020.             &lt;p&gt;I have enabled a PHP profiler, well magento, but it is still a profiler.
  1021. This is the standard magento compiler that records all the processing including all db queries to create the page, from receiving the request.&lt;/p&gt;
  1022.  
  1023. &lt;p&gt;&lt;a href=&quot;http://i.stack.imgur.com/KQaGY.png&quot; rel=&quot;nofollow&quot;&gt;&lt;img src=&quot;http://i.stack.imgur.com/KQaGY.png&quot; alt=&quot;mage-profiler&quot;&gt;&lt;/a&gt;&lt;/p&gt;
  1024.  
  1025. &lt;p&gt;I am testing with a the php built-in server hosted locally.&lt;/p&gt;
  1026.  
  1027. &lt;p&gt;The results show pretty decent server response times, but on the chrome developer tools the Time to first byte is much higher. Why is this?&lt;/p&gt;
  1028.  
  1029. &lt;p&gt;&lt;strong&gt;Take Note...the screenshots below of the timings are from the SAME REQUEST...CLEARLY&lt;/strong&gt;&lt;/p&gt;
  1030.  
  1031. &lt;p&gt;Profiler (www.mysite.com/index.php):&lt;/p&gt;
  1032.  
  1033. &lt;p&gt;&lt;a href=&quot;http://i.stack.imgur.com/13kag.png&quot; rel=&quot;nofollow&quot;&gt;&lt;img src=&quot;http://i.stack.imgur.com/13kag.png&quot; alt=&quot;magento-profiler-server-response&quot;&gt;&lt;/a&gt;&lt;/p&gt;
  1034.  
  1035. &lt;p&gt;Developer tools (www.mysite.com/index.php):&lt;/p&gt;
  1036.  
  1037. &lt;p&gt;&lt;a href=&quot;http://i.stack.imgur.com/ltfPC.png&quot; rel=&quot;nofollow&quot;&gt;&lt;img src=&quot;http://i.stack.imgur.com/ltfPC.png&quot; alt=&quot;TTFB-chrome-developer-tools&quot;&gt;&lt;/a&gt;&lt;/p&gt;
  1038.  
  1039.         </summary>
  1040.     </entry>
  1041.     <entry>
  1042.         <id>http://stackoverflow.com/q/21405899</id>
  1043.         <re:rank scheme="http://stackoverflow.com">0</re:rank>
  1044.         <title type="text">Xampp PHP Create COM Object Fatal Error without any info</title>
  1045.             <category scheme="http://stackoverflow.com/tags" term="php" />
  1046.             <category scheme="http://stackoverflow.com/tags" term="windows" />
  1047.             <category scheme="http://stackoverflow.com/tags" term="com" />
  1048.             <category scheme="http://stackoverflow.com/tags" term="xampp" />
  1049.         <author>
  1050.             <name>da.eXecutoR</name>
  1051.             <uri>http://stackoverflow.com/users/1414933</uri>
  1052.         </author>
  1053.         <link rel="alternate" href="http://stackoverflow.com/questions/21405899/xampp-php-create-com-object-fatal-error-without-any-info" />
  1054.         <published>2016-09-27T10:42:46Z</published>
  1055.         <updated>2016-09-27T10:42:46Z</updated>
  1056.         <summary type="html">
  1057.            
  1058.  
  1059.             &lt;p&gt;I&#39;m running into a problem with my php application. I&#39;m building up a service application which should be connected to our ERP ( selectline ).&lt;/p&gt;
  1060.  
  1061. &lt;p&gt;But I can&#39;t get to create a COM Object. This code:&lt;/p&gt;
  1062.  
  1063. &lt;pre&gt;&lt;code&gt;&amp;lt;?PHP
  1064. error_reporting(E_ALL);
  1065. session_start();
  1066. date_default_timezone_set(&#39;Europe/Zurich&#39;);
  1067. echo time();
  1068. $obj = new COM(&quot;fd6c8b29-e936-4a61-8da6-b0c12ad3ba00&quot;) or die(&quot;Unable to instantiate Word&quot;);
  1069. echo &quot;Loaded Word, version {$word-&amp;gt;Version}\n&quot;;
  1070. ?&amp;gt;
  1071. &lt;/code&gt;&lt;/pre&gt;
  1072.  
  1073. &lt;p&gt;Returns me:&lt;/p&gt;
  1074.  
  1075. &lt;blockquote&gt;
  1076.   &lt;p&gt;Fatal error: in C:\xampp\htdocs\com.php on line 21&lt;/p&gt;
  1077. &lt;/blockquote&gt;
  1078.  
  1079. &lt;p&gt;I got two environments:&lt;/p&gt;
  1080.  
  1081. &lt;p&gt;Server 2008 R2 + Xampp v3.1.0 |PHP 5.4.7&lt;/p&gt;
  1082.  
  1083. &lt;p&gt;Server 2012 R2 + Xampp v3.1.0 | PHP 5.4.7&lt;/p&gt;
  1084.  
  1085. &lt;p&gt;I had to add the php_com_dotnet.dll in the php.ini because I had COM class not found before.&lt;/p&gt;
  1086.  
  1087. &lt;p&gt;Due to the fact I&#39;m complete new to COM I have no idea where to search for the failure.&lt;/p&gt;
  1088.  
  1089. &lt;p&gt;May you guys can help me out.&lt;/p&gt;
  1090.  
  1091. &lt;p&gt;Thanks in advance&lt;/p&gt;
  1092.  
  1093. &lt;p&gt;I changed my code a bit:&lt;/p&gt;
  1094.  
  1095. &lt;pre&gt;&lt;code&gt;try {
  1096. $obj = new COM(&quot;word.application&quot;) or die(&quot;Unable to instantiate Word&quot;);
  1097. } catch (Exception $e) {
  1098. echo $e-&amp;gt;getMessage() . &quot;\n&quot;;
  1099. }
  1100. &lt;/code&gt;&lt;/pre&gt;
  1101.  
  1102. &lt;p&gt;Now I get:&lt;/p&gt;
  1103.  
  1104. &lt;blockquote&gt;
  1105.   &lt;p&gt;Failed to create COM object `word.application&#39;: Invalid Syntax&lt;/p&gt;
  1106. &lt;/blockquote&gt;
  1107.  
  1108. &lt;p&gt;I don&#39;t get what is wrong. According to this article &lt;a href=&quot;http://www.php.net/manual/en/class.com.php&quot; rel=&quot;nofollow&quot;&gt;http://www.php.net/manual/en/class.com.php&lt;/a&gt; there is no need for additional parameters, right? &lt;/p&gt;
  1109.  
  1110.         </summary>
  1111.     </entry>
  1112.     <entry>
  1113.         <id>http://stackoverflow.com/q/39568471</id>
  1114.         <re:rank scheme="http://stackoverflow.com">1</re:rank>
  1115.         <title type="text">oop model Base class design : static and non-static data access</title>
  1116.             <category scheme="http://stackoverflow.com/tags" term="php" />
  1117.             <category scheme="http://stackoverflow.com/tags" term="oop" />
  1118.         <author>
  1119.             <name>max</name>
  1120.             <uri>http://stackoverflow.com/users/590589</uri>
  1121.         </author>
  1122.         <link rel="alternate" href="http://stackoverflow.com/questions/39568471/oop-model-base-class-design-static-and-non-static-data-access" />
  1123.         <published>2016-09-27T12:19:42Z</published>
  1124.         <updated>2016-09-28T21:26:17Z</updated>
  1125.         <summary type="html">
  1126.            
  1127.  
  1128.             &lt;p&gt;I am trying to make a base class ... tiny framework if you will just for practice &lt;/p&gt;
  1129.  
  1130. &lt;p&gt;So I start with example of child class because it has less code !! &lt;/p&gt;
  1131.  
  1132. &lt;pre&gt;&lt;code&gt;class User extends Base {
  1133.  
  1134.     public $id ;
  1135.     public $username ;
  1136.     public $email ;
  1137.     public $password ;
  1138.  
  1139.     function __construct(){
  1140.         $this-&amp;gt;table_name = &#39;users&#39;;
  1141.         $this-&amp;gt;set_cols(get_class_vars(&#39;User&#39;));
  1142.     }
  1143.  
  1144. }
  1145.  
  1146. $u = new User;
  1147. $u-&amp;gt;username = &#39;jason&#39;;
  1148. $u-&amp;gt;email = &#39;j@gmail.com&#39;;
  1149. $u-&amp;gt;insert();
  1150. &lt;/code&gt;&lt;/pre&gt;
  1151.  
  1152. &lt;p&gt;Here is my Base class&lt;/p&gt;
  1153.  
  1154. &lt;pre&gt;&lt;code&gt;class Base {
  1155.  
  1156.   protected $table_name ;
  1157.   protected $table_columns ;
  1158.  
  1159.   protected function set_cols($cols){
  1160.  
  1161.       unset($cols[&#39;table_name&#39;]);
  1162.       unset($cols[&#39;table_columns&#39;]);
  1163.       $this-&amp;gt;table_columns = array_keys($cols);
  1164.   }
  1165.  
  1166.   public function insert(){
  1167.  
  1168.       $colums = $values = array();
  1169.  
  1170.       foreach($this-&amp;gt;table_columns as $col )
  1171.       {
  1172.         if(!$this-&amp;gt;$col) continue ;
  1173.         $values[] = $this-&amp;gt;$col ;
  1174.         $colums[] = $col ;
  1175.       }
  1176.  
  1177.  
  1178.       $values =  implode(&#39;,&#39; , $values);
  1179.       $colums =  implode(&#39;,&#39; , $colums);
  1180.  
  1181.     echo  $sql = &quot;INSTER INTO &quot;.$this-&amp;gt;table_name .&quot;   ($colums)
  1182.       VALUES ($values) &quot;;
  1183.   }
  1184.  
  1185. }
  1186. &lt;/code&gt;&lt;/pre&gt;
  1187.  
  1188. &lt;p&gt;Here is the problem , I want to make &lt;code&gt;filter&lt;/code&gt; or &lt;code&gt;get&lt;/code&gt; method (basically reading from database) static and then  return an array of objects from database data &lt;/p&gt;
  1189.  
  1190. &lt;pre&gt;&lt;code&gt;    class Base{
  1191.  
  1192.       static function filter($conditions =array()){
  1193.  
  1194.  
  1195.           $query_condition =  $conditions ; // some function to convert array to  sql string
  1196.  
  1197.           $query_result = &quot;SELECT * FROM  &quot;.$this-&amp;gt;table_name .&quot; WHERE  $query_condition &quot;;
  1198.           $export = array();
  1199.  
  1200.  
  1201.           $class = get_called_class();
  1202.           foreach($query_result as $q )
  1203.           {
  1204.               $obj =  new $class;  
  1205.  
  1206.               foreach($this-&amp;gt;table_columns as $col )
  1207.               $obj-&amp;gt;$col = $q[$col];
  1208.  
  1209.               $export[]  = $obj;
  1210.  
  1211.           }
  1212.  
  1213.       return $export;
  1214.    }
  1215. }
  1216.  
  1217. $users = User::filter([&#39;username&#39;=&amp;gt;&#39;jason&#39; , &#39;email&#39;=&amp;gt;&#39;j@gmail.com&#39;]);
  1218. &lt;/code&gt;&lt;/pre&gt;
  1219.  
  1220. &lt;p&gt;Here is the problem , with &lt;code&gt;filter&lt;/code&gt; as static function &lt;code&gt;__construct&lt;/code&gt; in &lt;code&gt;User&lt;/code&gt; class will not get called and &lt;code&gt;table_columns&lt;/code&gt;, &lt;code&gt;table_name&lt;/code&gt;  will be empty &lt;/p&gt;
  1221.  
  1222. &lt;p&gt;also in the &lt;code&gt;filter&lt;/code&gt; method I can&#39;t access them anyway because they are not static ... I can make a dummy &lt;code&gt;User&lt;/code&gt;  object in the &lt;code&gt;filter&lt;/code&gt; method and solve this problems but somehow it doesn&#39;t feel right &lt;/p&gt;
  1223.  
  1224. &lt;p&gt;Basically I have a design problem any suggestion is welcomed &lt;/p&gt;
  1225.  
  1226.         </summary>
  1227.     </entry>
  1228.     <entry>
  1229.         <id>http://stackoverflow.com/q/39688421</id>
  1230.         <re:rank scheme="http://stackoverflow.com">0</re:rank>
  1231.         <title type="text">Bug : Charts loading automatically (chart.js) (laravel 5.2)</title>
  1232.             <category scheme="http://stackoverflow.com/tags" term="javascript" />
  1233.             <category scheme="http://stackoverflow.com/tags" term="php" />
  1234.             <category scheme="http://stackoverflow.com/tags" term="jquery" />
  1235.             <category scheme="http://stackoverflow.com/tags" term="charts" />
  1236.             <category scheme="http://stackoverflow.com/tags" term="chart.js" />
  1237.         <author>
  1238.             <name>YaSh Chaudhary</name>
  1239.             <uri>http://stackoverflow.com/users/5107321</uri>
  1240.         </author>
  1241.         <link rel="alternate" href="http://stackoverflow.com/questions/39688421/bug-charts-loading-automatically-chart-js-laravel-5-2" />
  1242.         <published>2016-09-27T15:43:56Z</published>
  1243.         <updated>2016-09-27T15:45:06Z</updated>
  1244.         <summary type="html">
  1245.            
  1246.  
  1247.             &lt;p&gt;I am using &lt;strong&gt;chart.js&lt;/strong&gt; in laravel 5.2. When I go to my page ,all the charts are automatically loaded (but &lt;strong&gt;this should not happen&lt;/strong&gt;). Also,i am &lt;strong&gt;not using window.load&lt;/strong&gt; or window.onload function.&lt;/p&gt;
  1248.  
  1249. &lt;p&gt;It should open only on the click(here ,on clicking pic)&lt;/p&gt;
  1250.  
  1251. &lt;p&gt;&lt;strong&gt;my code:&lt;/strong&gt; (for 1 chart):&lt;/p&gt;
  1252.  
  1253. &lt;pre&gt;&lt;code&gt;  &amp;lt;body id=&quot;abc&quot;&amp;gt;
  1254.  
  1255.   &amp;lt;div class=&quot;container-fluid&quot;&amp;gt;
  1256.   &amp;lt;div id=&quot;myNav1&quot; class=&quot;overlay&quot;&amp;gt;
  1257.   &amp;lt;a href=&quot;javascript:void(0)&quot; class=&quot;closebtn&quot; onclick=&quot;closeNav1()&quot;&amp;gt;&#215;&amp;lt;/a&amp;gt;
  1258.   &amp;lt;div class=&quot;overlay-content&quot;&amp;gt;
  1259.  
  1260. &amp;lt;script&amp;gt;
  1261.  
  1262.     var year1 = [&#39;FIRST&#39;,&#39;SECOND&#39;,&#39;THIRD&#39;, &#39;FOURTH&#39; , &#39;FIFTH&#39;];
  1263.     var data_viewer = &amp;lt;?php echo $viewer; ?&amp;gt;;
  1264.     var data_viewer1 = &amp;lt;?php echo $viewer1; ?&amp;gt;;
  1265.     var data_viewer2 = &amp;lt;?php echo $viewer2; ?&amp;gt;;
  1266.     var data_viewer3 = &amp;lt;?php echo $viewer3; ?&amp;gt;;
  1267.     var data_viewer4 = &amp;lt;?php echo $viewer4; ?&amp;gt;;
  1268.     var data_viewer5 = &amp;lt;?php echo $viewer5; ?&amp;gt;;
  1269.     var data_click = &amp;lt;?php echo $click; ?&amp;gt;;
  1270.     var data_click1 = &amp;lt;?php echo $click1; ?&amp;gt;;
  1271.     var data_click2 = &amp;lt;?php echo $click2; ?&amp;gt;;
  1272.     var data_click3 = &amp;lt;?php echo $click3; ?&amp;gt;;
  1273.     var data_click4 = &amp;lt;?php echo $click4; ?&amp;gt;;
  1274.     var data_click5 = &amp;lt;?php echo $click5; ?&amp;gt;;
  1275.  
  1276.  
  1277.     var barChartData1 = {
  1278.  
  1279.         labels: year1,
  1280.  
  1281.         datasets: [{
  1282.  
  1283.             label: &#39;STUDS&#39;,
  1284.  
  1285.             backgroundColor: &quot;rgba(65,105,225,0.5)&quot;,
  1286.  
  1287.             data: data_click
  1288.  
  1289.         }, {
  1290.  
  1291.             label: &#39;ANGELS&#39;,
  1292.  
  1293.             backgroundColor: &quot;rgba(255,105,180,0.5)&quot;,
  1294.  
  1295.             data: data_viewer
  1296.  
  1297.         }],
  1298.  
  1299.  
  1300.  
  1301.     };
  1302.  
  1303.     function chart1(){
  1304.  
  1305.         var ctx1 = document.getElementById(&quot;canvas1&quot;).getContext(&quot;2d&quot;);
  1306.  
  1307.         var myBar1 = new Chart(ctx1, {
  1308.  
  1309.  
  1310.             type: &#39;horizontalBar&#39;,
  1311.  
  1312.             data: barChartData1,
  1313.  
  1314.             options: {
  1315.  
  1316.                 elements: {
  1317.  
  1318.                     rectangle: {
  1319.  
  1320.                         borderWidth: 2,
  1321.  
  1322.                         borderColor: &#39;rgb(169, 169, 169)&#39;,
  1323.  
  1324.                         borderSkipped: &#39;bottom&#39;
  1325.  
  1326.  
  1327.  
  1328.                     }
  1329.  
  1330.                 },
  1331.  
  1332.                 scales: {
  1333.                 xAxes: [{
  1334.                     ticks: {
  1335.                         min: 0,
  1336.                         beginAtZero: true
  1337.                     }
  1338.                 }]
  1339.             },
  1340.  
  1341.  
  1342.                 responsive: true,
  1343.  
  1344.                 title: {
  1345.  
  1346.                     display: true,
  1347.  
  1348.                     text: &#39;RATING CHART&#39;
  1349.  
  1350.                 }
  1351.  
  1352.             }
  1353.  
  1354.  
  1355.         });
  1356.  
  1357.  
  1358.     };
  1359.  
  1360. setTimeout(chart1, 30)
  1361.  
  1362. &amp;lt;/script&amp;gt;
  1363.  
  1364.   &amp;lt;script&amp;gt;
  1365. function openNav1() {
  1366.     document.getElementById(&quot;myNav1&quot;).style.width = &quot;100%&quot;;
  1367.     chart1();
  1368.  
  1369. }
  1370.  
  1371. function closeNav1() {
  1372.     document.getElementById(&quot;myNav1&quot;).style.width = &quot;0%&quot;;
  1373. }
  1374. &amp;lt;/script&amp;gt;
  1375. &lt;/code&gt;&lt;/pre&gt;
  1376.  
  1377.         </summary>
  1378.     </entry>
  1379. </feed>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement