511 search results

Auto-Provide jQuery for Mischievous Packages

…is already scanning all of our code. When you enable this feature, each time it finds a jQuery or $ variable- anywhere in any of the code that we use - that is uninitialized, it replaces it with require('jquery'). It basically rewrites the broken code…

6:37
Copying Files

…directory. To make life more joyful, Encore has a feature for exactly this situation. Open up webpack.config.js. And, anywhere in here, say .copyFiles() and pass this a configuration object: Obviously... this function helps you copy files from one place to another. Neato! But..…

8:11
Reordering the Files

…nicer. Pass a second argument to create(): an array of options. Pass one called handle set to .drag-handle. With this, instead of being able to grab anywhere to start sorting, we'll only be able to grab elements with this class. Down in render…

5:10
Deploying Keys & Private Repos

…that public key. Actually, none of this is special to git, this is how SSH key-based authentication works anywhere. Even though our repository is still public, you need some valid SSH key pair in order to authenticate... and our server has nothing. That's…

8:40
Setup: Server Provisioning

…In our Ansible tutorial, we created a small playbook - aws.yml - whose only job is to boot an EC2 instance using an Ubuntu 14.04 image. You're free to get a server from anywhere... but if you do want to use this script to…

8:38
Skipping Tasks based on Changed

…add when: code_changed: Ah, so nice. Copy that and put it anywhere else it makes sense like "Execute migrations" and "Clear Cache": Phew! Ok, run the playbook - but take off the verbose flag: ansible-playbook ansible/playbook.yml -i ansible/hosts.ini -t deploy…

3:01
Extensions, php.ini & lineinfile

…item. That works because Ansible has this nice with_items loop feature. And notice, this is not special to the apt module - it'll work anywhere. Oh, and those quotes are important: Quoting is usually optional in YAML. But if a value starts with {{, it…

7:23
PHP 7, Nginx & MySQL

…mootube.l from our host machine. To handle that, head to your terminal on your main machine - so not the VM - and edit your /etc/hosts file. Inside, anywhere, add 192.168.33.10 mootube.l. Save that! Back at the browser test it: http…

6:09
Functions, Filters and Debugging with dump

…then use the number_format to show only one decimal place: In fact, functions and filters can be used anywhere. Let's use the length filter to print a message if there are no penguin products for sale: This filter takes an array or collection…

5:50
Doing Crazy things with Foundry & Fixtures

…that's now configured to create multiple objects. Pass 1, 5 to create anywhere from 1 to 5 QuestionTag objects. Try the fixtures again: No errors! And if we SELECT * FROM question: We only have 25 rows: the correct amount! That's the 20 published.…

8:59
Behat Best Practices with Symfony

…Behat is a behavior driven development tool. The name comes from behavior testing, but that's not documented anywhere that I know about. So it's a secret for you. So, what's behavior Liz Keogh says BDD is when you use examples in conversations…

43:32
Fetch the User Object

…we can call, getEmail() on it. Do that: ->getEmail(): Cool! Move over and refresh. No errors. Click anywhere down on the web debug toolbar to get into the profiler. Go to the logs tab, click "Debug" and... down a bit, there it is! Checking account…

7:30
Role Hierarchy

… But... don't worry! Symfony has our backs with a sweet feature called role_hierarchy. Open config/packages/security.yaml. Anywhere inside, I'll do it above firewalls, add role_hierarchy. Below, put ROLE_ADMIN set to an array with ROLE_ADMIN_COMMENT and ROLE…

4:49
Bootstrapping the Bundle & Autoloading

…move the KnpUIpsum class into that directory. And yea, you could put this into a src/Service directory, or anywhere else you want. Oh, but this namespace will not work anymore. We need a namespace that's custom to our bundle. It could be anything…

7:21
jQuery Plugins / Bootstrap

…! This is where things get really interesting. At this point, we're no longer using the global jQuery variable or Bootstrap JavaScript anywhere: all of our code now uses proper require statements. To celebrate, remove the two script tags from the base layout: And now…

6:45
Creating a Service Class

…click one of the genuses. Yes! The fun fact is screaming at us in upper case. So believe it or not: you just saw one of the most important and commonly-confusing object-oriented strategies that exist anywhere... in any language! And it's this…

3:11
The Form Type Class

…in the new GenusAdminController. To create a form, you'll add a class where you'll describe what the form looks like. In PhpStorm, select anywhere in your bundle and press command+N, or right click and select "New". Find "Form" and call it GenusFormType…

3:14
Users Need Passwords (plainPassword)

…little evil. Finally, in eraseCredentials(), add $this->plainPassword = null: Symfony calls this after logging in, and it's just a minor security measure to prevent the plain-text password from being accidentally saved anywhere. The User object is perfect. Let's add the listener.

3:32
Mad Test Debugging

…is really easy. The class that handles the styling is called ConsoleOutput, and you can use it directly from anywhere. Start by adding a private $output property that we'll use to avoid creating a bunch of these objects. Then down in printDebug(), say if…

3:03
The All-Important HttpExceptionInterface

…error, unless that exception implements the HttpExceptionInterface: It has two functions: getStatusCode() and getHeaders(). The HttpException class we're throwing implements this. That means we can throw this from anywhere in our code, stop the flow, but control the status code of the response. Symfony…

4:44