Categories
Workflow

QCachegrind

I installed it with homebrew. That put it in:

/usr/local/Cellar/qcachegrind/18.04.1
open qcachegrind.app

Boom, you got a GUI.

Open cachegrind files that I have in /var/tmp.
Need to enable xdebug profiling for these to exist.

Categories
PHP Workflow

Xdebug Profiling

Installed xdebug with pecl install xdebug.

Enabled in extra .ini config file in:

/usr/local/etc/php/7.2/conf.d

Restart PHP with:

brew services restart php72

The webcachegrind script does not seem to work. It lists only a few of the cache files, and they often do not match their description. For example the filename will appear to be webcachegrinds own PHP script, but all the data relates to a different WordPress script. Out of sync with the requests.

Might need a different tool like QCachegrind.

Currently cachegrind files are in /private/var/tmp

Categories
Servers

Changing PHP Upload limit on my Binary Lane VPS

php.ini is at /etc/php/7.3/fpm/php.ini

Change max_upload and post_max sizes (not their exact name, do a search for current value).

Restart PHP with this command:

service php7.3-fpm restart
Categories
JavaScript

JavaScript Thingies

Destructuring

let idaCalledEm, others
[idaCalledEm, ...others] = ['Chazwazzars', 'Simpsons', 'or perhaps', 'Futurama Quote']

To Do: Incorporate Wes Bos’ default object parameter post.

Categories
Uncategorized

Patterns That Pay Off

Notes from Matt Stauffer’s talk.


/*
View Model
*/
class DashboardViewModel
{
    function topTasks()
    {
        $overdue = $this->overDueTasks();
        return array_merge($overdue, $this->fillTasksDueSoon( count($overdue) ));
    }

    function progressChart()
    {
        return [
            'complete' => $this->progressDone(),
            'date_markers' => $this->dateMarkers()
        ];
    }

}

return view('dashboard')->with('vm', new DashboardViewModel($user));

?>

View Data Composition

Presenter
    Layer above other thing, usually the model, to give it more powers.

View Model
    PHP Object for organizing this logic 

Responsable (sic)
    interface in Laravel for PHP object that can be converted to Response 

View Models

These seem fairly easy to understand. A class that wraps a model, providing methods for data access that a view will need. Moves the complexity of querying out of Controller.

And nicer than putting straight on model which complicates it in a lot of unrelated contexts.

Categories
Frontend

Data List HTML suggestions

<input type="text" list="planets">
<datalist id="planets">
    <option value="Mercury"></option>
    <option value="Venus"></option>
    <option value="Earth"></option>
</datalist>
Categories
Servers

503 Bad Gateway on Ubuntu Server

Rebooted Ubuntu web server and PHP-FPM wasn’t running.
Just needed the old:

service php7.3-fpm start
Categories
Servers

Remove Non-Empty Directory

rm -rf my_directory_name

Be careful.

Categories
JavaScript Laravel

Encoding strings for Vue components

If you’re passing server side data from a Laravel Blade template into a Vue component prop, the standard {{ encoding }} structure won’t work. The HTML encoding is parsed by Vue and will break the template parsing.

<coffee-history-list
  :name='@json($cafe->name)'
>
</coffee-history-list>

Using Blade’s @json directive will escape the quotes correctly, but the prop value must be wrapped in single, not double quotes.

Categories
Workflow

Fixing the PHP-FPM User/Group File Permissions

After upgrading to PHP7.2 php-fpm was running as the _www user. PHP worked, but was unable to write to most files.

Needed to change php-fpm to use my own Mac user and group. Biggest difficulty was finding where my actual version of Apache & PHP are configured and where error logs are written. This is due to Homebrew adding to the native installs.

Try these paths if it happens again.
(May not be correct as I tried a lot of things to get this fixed)

Apache

Config  /usr/local/Cellar/httpd24/2.4.27
Logs   /usr/local/var/log/apache2

(Defined in /usr/local/etc/apache2/2.4/)

PHP

/usr/local/etc/php/7.2/php-fpm.d