Skip to content

Instantly share code, notes, and snippets.

View nehalist's full-sized avatar

Kevin nehalist

View GitHub Profile
const Child: FunctionComponent<{ someprop: number }> = () => {
return <>child</>
};
const Foo: FunctionComponent<{ fooprop: boolean }> = (props) => (
<Child {...props} />
);
// IDE properly complains since `someprop` is missing in props of Foo
const CUSTOM_PROPS = 'custom:properties';
function Expose(target: object, key: string) {
let properties: string[] | undefined = Reflect.getMetadata(CUSTOM_PROPS, target);
if (! properties) {
properties = [];
}
properties.push(key);

I've always been a heavy IDE user - but for some things, like running tests, I still prefered a terminal. Recently I've played around with the in-IDE possibilities for testing and was pretty satisfied with them. Since Symfony ships with a kinda custom testing experience here's how to setup your IDE to test your Symfony applications with it - and additional features of testing within your IDE.

IDE configuration

After following the current Testing documentation it's mandatory to manually run ./bin/phpunit once in your terminal. Symfony will install its own instance of PHPUnit within your bin directory which will provide the executable phpunit file for our IDE.

After you've run this command you'll see a .phpunit directory within your bin directory.

For being able to run your tests via your IDE open your Settings window and navigate to Languages & Frameworks > PHP > Test Frameworks.

# If you come from bash you might have to change your $PATH.
# export PATH=$HOME/bin:/usr/local/bin:$PATH
export PATH=/home/kh/.npm-global/bin:$PATH
# Path to your oh-my-zsh installation.
export ZSH=/home/kh/.oh-my-zsh
# Set name of the theme to load. Optionally, if you set this to "random"
# it'll load a random theme each time that oh-my-zsh is loaded.
<?php
class DefaultController extends Controller
{
/**
* @Route("/", name="homepage")
*/
public function indexAction(Request $request)
{
$this->get('monolog.logger.user_action_db')->info('test');
import {ConfigurationLoaderInterface} from "./ConfigurationLoaderInterface";
export class JsonConfigurationLoader implements ConfigurationLoaderInterface {
handle(file: string): Object {
return require(file);
}
}
// config.xml
[...]
<frontend>
<layout>
<updates>
<foobar>
<file>foobar.xml</file>
</foobar>
</updates>
</layout>
module.exports = function(grunt) {
grunt.config.set('ts', {
assets: {
files: [
{
expand: true,
cwd: 'assets/js/',
src: [
'**/*.ts'
],
// models/Project.js
module.exports = {
attributes: {
title: {
type: Sequelize.STRING
}
},
associations: function() {
Project.belongsTo(Customer);
Project.hasMany(Contributor);
# service
@app.factory 'CurrentUser', ($http) ->
$http({
method: 'GET',
url: 'users/me'
}).then (user) =>
# i want to return the user object
return # ... what?