windows['VueMode'] = process.env.NODE_ENV;
Note: If you would like to use process.env.NODE_ENV in a sub component, put it inside one of the lifecycle hooks. For example, created, or mounted.
windows['VueMode'] = process.env.NODE_ENV;
# simple line counter
counter line_count
/$/ {
line_count++
}
FROM centos:centos7
RUN curl 'https://setup.ius.io/' -o setup-ius.sh \
&& bash setup-ius.sh \
&& rm -f setup-ius.sh \
&& yum -y update \
&& yum -y install \
php71u-common \
php71u-cli \
php71u-fpm \
php71u-opcache \
php71u-xml \
php71u-json \
php71u-pdo \
php71u-mysqlnd \
php71u-intl \
php71u-mbstring \
php71u-mcrypt \
php71u-gd \
php71u-soap \
php71u-process \
php71u-pecl-redis \
php71u-pecl-xdebug \
php71u-fpm-httpd
EXPOSE 9000
CMD ["php-fpm", "-F"]
; Change ownership:
user = php-fpm
group = php-fpm
; Note: Ubuntu uses www-data user. Add php-fpm user to www-data group if the other container used it.
; # groupadd -g 33 www-data
; # useradd www-data -m -c 'web user' -u 33 -g 33
; # usermod -a -G www-data php-fpm
; # id php-fpm
; Now, restart this container to ensure php-fpm user is in www-data group.
; Bind port 9000 to the all interfaces:
listen = 9000
;listen = [::]:9000
; Note: PHP-FPM has a listen.client_allowed setting which allows you to set a list of IPs that can connect, or leave blank for any IP to connect. However, even with it being left blank, the issue still persisted. Digging into the official PHP-FPM repo, I discovered that you also need to set listen = [::]:9000 which then began to allow any IP to connect.
; Note: https://stackoverflow.com/questions/19806945/docker-and-connections-between-containers
; Comment out the following line:
;listen.allowed_clients = 127.0.0.1
; Note: "listen.allowed_clients = any" will not work.
; Note: "listen.allowed_clients = other-container-name" will not work. IP address only.
; Uncomment the following line to debug the issue:
catch_workers_output = yes
; Note: Comment it out on production.
### xdebug setting
###
; Enable xdebug extension module
zend_extension=xdebug.so
;zend_extension=/usr/lib64/php/modules/xdebug.so
xdebug.default_enable=1
xdebug.remote_enable=1
xdebug.remote_handler=dbgp
xdebug.remote_host=localhost
xdebug.remote_port=9009
; Note: php-fpm uses port 9000 as well.
xdebug.remote_log=/tmp/xdebug.log
xdebug.remote_connect_back=0
xdebug.remote_autostart=0
xdebug.remote_mode=req
xdebug.max_nesting_level=1000
FROM alpine:latest
RUN apk --no-cache add shadow \
&& usermod -u 2500 elasticsearch \
&& groupmod -g 2500 elasticsearch
Caused by: javax.net.ssl.SSLHandshakeException: java.security.cert.CertificateException: No subject alternative names matching IP address XXXXX found
at sun.security.ssl.Alerts.getSSLException(Unknown Source) ~[na:1.8.0_51]
at sun.security.ssl.SSLSocketImpl.fatal(Unknown Source) ~[na:1.8.0_51]
Hashtable<String, Object> objEnvironment;
objEnvironment = new Hashtable<String, Object>(11);
objEnvironment.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
objEnvironment.put(Context.PROVIDER_URL, "LDAPS://domain:636");
objEnvironment.put(Context.SECURITY_AUTHENTICATION, "simple");
objEnvironment.put(Context.SECURITY_PRINCIPAL, <username>);
objEnvironment.put(Context.SECURITY_CREDENTIALS, <Password>);
objEnvironment.put("java.naming.ldap.attributes.binary", <attributes>);
System.setProperty("javax.net.ssl.trustStore", "certificates".concat(File.separator).concat("cacerts"));
this.objLDAPContext = new InitialLdapContext(objEnvironment, null);
Improve LDAP support Endpoint identification has been enabled on LDAPS connections.
To improve the robustness of LDAPS (secure LDAP over TLS ) connections, endpoint identification algorithms have been enabled by default.
Note that there may be situations where some applications that were previously able to successfully connect to an LDAPS server may no longer be able to do so. Such applications may, if they deem appropriate, disable endpoint identification using a new system property: com.sun.jndi.ldap.object.disableEndpointIdentification.
Define this system property (or set it to true) to disable endpoint identification algorithms.
package main
import (
"fmt"
"log"
"net/http"
)
func handler(w http.ResponseWriter, r *http.Request) {
fmt.Printf("Hello World\n")
fmt.Fprintf(w, "Hi there, I love %s!", r.URL.Path[1:])
}
func main() {
http.HandleFunc("/", handler)
log.Fatal(http.ListenAndServe(":8080", nil))
}
#
FROM alpine:latest
RUN apk --no-cache add ca-certificates
COPY main /usr/local/bin
CMD /usr/local/bin/main
mysql> SHOW PROCESSLIST;
mysql> SHOW STATUS LIKE '%connections%';
mysql> SHOW STATUS LIKE '%threads%';
Check network connection files:
db.SetMaxOpenConns(1000)
db.SetMaxIdleConns(300)
db.SetConnMaxLifetime(0)
rows, err := db.Query("select name from beehives")
if err != nil {
panic(err)
}
defer rows.Close()
total used free shared buff/cache available
Mem: 3.8G 940M 115M 5.6M 2.8G 2.6G
Swap: 4.0G 0B 4.0G
Filename Type Size Used Priority
/myswap file 4194300 0 -1
/myswap swap swap defaults 0 0
/myswap swap swap defaults 0 0
SwapCached: 0 kB
SwapTotal: 4194300 kB
SwapFree: 4194300 kB
30
dev/xvdd swap swap defaults 0 0
2018-09-22T15:00:42.130042Z 0 [Warning] Changed limits: max_open_files: 1024 (requested 5000)
2018-09-22T15:00:42.130087Z 0 [Warning] Changed limits: max_connections: 214 (requested 500)
2018-09-22T15:00:42.130091Z 0 [Warning] Changed limits: table_open_cache: 400 (requested 2000)
[Service]
LimitNOFILE=infinity
LimitMEMLOCK=infinity
%sudo ALL=(ALL:ALL) NOPASSWD: ALL
orUSER_NAME ALL=(ALL) NOPASSWD: ALL
PasswordAuthentication = yes
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQClKsfkNkuSevGj3eYhCe53pcjqP3maAhDFcvBS7O6V
hz2ItxCih+PnDSUaw+WNQn/mZphTk/a/gU8jEzoOWbkM4yxyb/wB96xbiFveSFJuOp/d6RJhJOI0iBXr
lsLnBItntckiJ7FbtxJMXLvvwJryDUilBMTjYtwB+QhYXUMOzce5Pjz5/i8SeJtjnV3iAoG/cQk+0FzZ
qaeJAAHco+CY/5WrUBkrHmFJr6HcXkvJdWPkYQS3xqC0+FmUZofz221CBt5IMucxXPkX4rWi+z7wB3Rb
BQoQzd8v7yeb7OzlPnWOyN0qFU0XA246RA8QFYiCNYwI3f05p6KLxEXAMPLE
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQClKsfkNkuSevGj3eYhCe53pcjqP3maAhDFcvBS7O6V
hz2ItxCih+PnDSUaw+WNQn/mZphTk/a/gU8jEzoOWbkM4yxyb/wB96xbiFveSFJuOp/d6RJhJOI0iBXr
lsLnBItntckiJ7FbtxJMXLvvwJryDUilBMTjYtwB+QhYXUMOzce5Pjz5/i8SeJtjnV3iAoG/cQk+0FzZ
qaeJAAHco+CY/5WrUBkrHmFJr6HcXkvJdWPkYQS3xqC0+FmUZofz221CBt5IMucxXPkX4rWi+z7wB3Rb
BQoQzd8v7yeb7OzlPnWOyN0qFU0XA246RA8QFYiCNYwI3f05p6KLxEXAMPLE
48 65 6c 6c 6f
package main
import (
"fmt"
"regexp"
)
func mapSubexpNames(m, n []string) map[string]string {
m, n = m[1:], n[1:]
r := make(map[string]string, len(m))
for i, _ := range n {
r[n[i]] = m[i]
}
return r
}
func main() {
r := regexp.MustCompile(`(?P<Year>\d{4})-(?P<Month>\d{2})-(?P<Day>\d{2})`)
m := r.FindStringSubmatch(`2015-05-27`)
n := r.SubexpNames()
fmt.Println(mapSubexpNames(m, n))
}
username ALL=(ALL) NOPASSWD: ALL
<script src="https://unpkg.com/vue/dist/vue.js"></script>
<div id="app">
<p>Expected output: <code>{{ JSON.stringify(expected) }}</code></p>
<component @emission="hearEmission">complete data, without extras</component>
<component @emission="hearEmission('extra', ...arguments)">with extras, incomplete data</component>
<component @emission="function (a, b, c) { hearEmission('extra', a, b, c) }">expected, overly explicit</component>
<ol class="log">
<li v-for="line in logs"><code>{{ JSON.stringify(line) }}</code></li>
</ol>
</div>
Vue.component('component', {
template: '<button @click="emitEvent"><slot></slot></button>',
methods: {
emitEvent: function() {
this.$emit('emission', 1, 2, 3);
}
}
});
new Vue({
el: '#app',
data: {
logs: [],
expected: ['extra', 1, 2, 3]
},
methods: {
hearEmission: function(extra, a, b, c) {
this.logs.push([extra, a, b, c]);
if (this.logs.length === 11) {
this.logs.splice(0, 1);
}
}
}
})
function saveSvg(svgEl, name) {
svgEl.setAttribute("xmlns", "http://www.w3.org/2000/svg");
var svgData = svgEl.outerHTML;
var preface = '<?xml version="1.0" standalone="no"?>\r\n';
var svgBlob = new Blob([preface, svgData], {type:"image/svg+xml;charset=utf-8"});
var svgUrl = URL.createObjectURL(svgBlob);
var downloadLink = document.createElement("a");
downloadLink.href = svgUrl;
downloadLink.download = name;
document.body.appendChild(downloadLink);
downloadLink.click();
document.body.removeChild(downloadLink);
}
saveSvg(svg, 'test.svg');
screen-256color 41 146
41 146
; reload the autohotkey script.
^!r::Reload
; input date and time
#d::
FormatTime, mydatetime,, M/d/yyyy HH:mm:ss
SendInput, %mydatetime%
return
; input date
#f::
FormatTime, mydate,, M/d/yyyy
SendInput, %mydate%
return
; input date
#y::
FormatTime, mydate,, yyyy-MM-dd
SendInput, %mydate%
return
; press ctrl-alt 1
^!1::
SendInput, Hello World
return
; In command prompt window, press shift + insert to paste from clipboard
#IfWinActive ahk_class ConsoleWindowClass
<+Insert::
SendInput, {Raw}%clipboard%
return
#IfWinActive
(new TextEncoder('utf-8').encode('foo')).length
javascript:(function inject(options, callback) { var load = function(path, callback) { var head = document.getElementsByTagName('head')[0]; var s = document.createElement('script'); s.src = options.baseUrl + "/" + path; head.appendChild(s); s.onload = s.onreadystatechange = function(_, isAbort) { if (isAbort || !s.readyState || s.readyState == "loaded" || s.readyState == "complete") { s = s.onload = s.onreadystatechange = null; if (!isAbort) callback(); } }; }; var pending = []; var transform = function(el) { pending.push(el) }; load("ace.js", function() { ace.config.loadModule("ace/ext/textarea", function(m) { transform = function(el) { if (!el.ace) el.ace = m.transformTextarea(el, options.ace); }; pending = pending.forEach(transform); callback && setTimeout(callback); }); }); if (options.target) return transform(options.target); window.addEventListener("click", function(e) { if (e.detail == 3 && e.target.localName == "textarea") transform(e.target); });})({"selectionStyle":"line","highlightActiveLine":true,"highlightSelectedWord":true,"readOnly":false,"copyWithEmptySelection":false,"cursorStyle":"ace","mergeUndoDeltas":true,"behavioursEnabled":true,"wrapBehavioursEnabled":true,"keyboardHandler":"ace/keyboard/vim","hScrollBarAlwaysVisible":false,"vScrollBarAlwaysVisible":false,"highlightGutterLine":true,"animatedScroll":false,"showInvisibles":false,"showPrintMargin":false,"printMarginColumn":80,"printMargin":false,"fadeFoldWidgets":false,"showFoldWidgets":true,"showLineNumbers":true,"showGutter":true,"displayIndentGuides":true,"fontSize":"12px","scrollPastEnd":0,"theme":"textmate","scrollSpeed":2,"dragDelay":0,"dragEnabled":true,"focusTimeout":0,"tooltipFollowsMouse":true,"firstLineNumber":1,"overwrite":false,"newLineMode":"auto","useWorker":true,"useSoftTabs":true,"navigateWithinSoftTabs":false,"tabSize":4,"wrap":"off","indentedSoftWrap":true,"foldStyle":"markbegin","mode":"javascript","enableMultiselect":true,"enableBlockSelect":true,"baseUrl":"https://ajaxorg.github.io/ace-builds/src-noconflict"})
func getProp(d interface{}, label string) (interface{}, bool) {
switch reflect.TypeOf(d).Kind() {
case reflect.Struct:
v := reflect.ValueOf(d).FieldByName(label)
return v.Interface(), true
}
return nil, false
}
strconv.ParseUint("123", 10, 32)
strconv.FormatUint(uint64(123), 10)
(function($) {
$(document).ready(function(){
// ajax global default setting
$.ajaxSetup({
contentType: 'Content-Type: application/json',
method: 'POST',
dateType: 'json',
});
//
let obj = {Asdf: 'asdf'};
$.ajax({
url: '/admin/region/request',
data: JSON.stringify(obj),
}).done(function(data) {
console.log(data);
}).fail(function(jqXHR, textStatus) {
console.log(jqXHR.responseJSON);
}).always(function(data) {
});
});
})(jQuery);
let formData = new FormData($('#RegionForm')[0]);
for (let [key, val] of formData.entries()) {
console.log(key + ': ' + val);
}
document.querySelector('form').addEventListener('submit', (e) => {
const formData = new FormData(e.target);
// Now you can use formData.get('foo'), for example.
for (let pair of formData.entries()) {
console.log(pair[0] + ', ' + pair[1]);
}
// Don't forget e.preventDefault() if you want to stop normal form .submission
});
cmd /c "regedit /e "%USERPROFILE%\Desktop\putty-sessions.reg" HKEY_CURRENT_USER\Software\SimonTatham\PuTTY\Sessions"
<VirtualHost *:80>
ServerName symfony.local
Include "conf-available/php7.2-fpm.conf"
ServerAdmin webmaster@localhost
DocumentRoot /var/www/symfony.local/curr/public
<Directory /var/www/symfony.local/curr/web>
AllowOverride All
</Directory>
</VirtualHost>
$arr = [
'test 0' => 'test 0',
'test 0' => 'test 0',
'test 0' => 'test 0',
'test 0' => 'test 0',
'test 0' => 'test 0',
'test 0' => 'test 0',
];
ctrl-v jjjjjj g ctrl-a a
// Reference:
// https://github.com/henrytseng/dataobject-parser
/**
* Dependencies
*/
// True if Object
function _isObject(value) {
return typeof(value) === 'object' && value !== null;
}
// True if Array
function _isArray(value) {
return Array.isArray(value);
}
/// True if type is string
function _isString(value) {
return typeof(value) === 'string';
}
// True if undefined
function _isUndefined(value) {
return typeof(value) === 'undefined';
}
// True if Number
function _isNumber(value) {
return typeof(value) === 'number';
}
// True if Boolean
function _isBoolean(value) {
return typeof(value) === 'boolean';
}
// True if Date object
function _isDate(value) {
return value instanceof Date;
}
function DataObjectParser($data){
this._data = $data || {};
}
/**
* Given a dot deliminated string set will create an object
* based on the structure of the string with the desired value
*
* @param {[String} $path path indicating where value should be placed
* @param {Mixed} $value the value desired to be set at the location determined by path
*/
DataObjectParser.prototype.set = function($path, $value) {
if(!$path || $path==='') return void 0;
var _self = this;
var re = /[\$\w-|]+|\[\]|([^\[[\w]\]]|["'](.*?)['"])/g;
// parse $path on dots, and brackets
var pathList = $path.match(re);
var parent = this._data;
var parentKey;
var grandParent = null;
var grandParentKey = null;
var addObj = function($obj, $key, $data) {
if($key === '[]') {
$obj.push($data);
} else {
$obj[$key] = $data;
}
};
while(pathList.length > 0) {
parentKey = pathList.shift().replace(/["']/g, '');
// Number, treat it as an array
if (!isNaN(+parentKey) || parentKey === "[]") {
if(!_isArray(parent) /* prevent overwritting */ ) {
parent = [];
addObj(grandParent, grandParentKey, parent);
}
// String, treat it as a key
} else if (_isString(parentKey)) {
if(!_isObject(parent)) {
parent = {};
addObj(grandParent, grandParentKey, parent);
}
}
// Next
grandParent = parent;
grandParentKey = parentKey;
parent = parent[parentKey];
}
addObj(grandParent, grandParentKey, $value);
return this;
};
/**
* Returns the value defined by the path passed in
*
* @param {String} $path string leading to a desired value
* @return {Mixed} a value in an object
*/
DataObjectParser.prototype.get = function($path) {
var data = this._data;
var regex = /[\$\w-|]+|\[\]|([^\[[\w]\]]|["'](.*?)['"])/g;
//check if $path is truthy
if (!$path) return void 0;
//parse $path on dots and brackets
var paths = $path.match(regex);
//step through data object until all keys in path have been processed
while (data !== null && paths.length > 0) {
if(data.propertyIsEnumerable(paths[0].replace(/"/g, ''))){
data = data[paths.shift().replace(/"/g, '')];
}
else{
return undefined;
}
}
return data;
};
DataObjectParser.prototype.data = function($data) {
if(!_isUndefined($data)) {
this._data = $data;
return this;
}
return this._data;
};
/**
* "Transposes" data; receives flat data and returns structured
*
* @param {Object} $data Structured object
* @return {DataObjectParser} An instance of a DataObjectParser
*/
DataObjectParser.transpose = function($flat) {
var parser = (new DataObjectParser());
for(var n in $flat) {
if($flat[n]!==undefined) {
parser.set(n, $flat[n]);
}
}
return parser;
};
/**
* "Untransposes" data object; opposite of transpose
*
* @param {Mixed} $structured A Object or a DataObjectParser
* @return {Object} Flat object
*/
DataObjectParser.untranspose = function($structured) {
//check to see if $structured is passed
$structured = $structured || {};
//handles if an object or a dataObjectParser is passed in
var structuredData = $structured._data || $structured;
var traverse = function($data, $isIndex) {
var result = [];
var createMapHandler = function($name, $data) {
return function($item, $i) {
var name = $name;
//check if $name is a key of form "hello.world"
if((/\./).test($name)) name = '["'+name+'"]';
//add name to $item.key
$item.key.unshift(name+".");
//return $item.key with updated key
return {
key: $item.key,
data: $item.data
};
};
};
for(var name in $data) {
var modifiedName;
// check if current name is an arrays index
if($isIndex) modifiedName = "["+name+"]";
else modifiedName = name;
// check if current name is linked to a value
if(_isString($data[name]) || _isNumber($data[name]) || $data[name]===null || _isBoolean($data[name]) || _isDate($data[name])) {
if((/\./).test(name)) modifiedName = '["'+name+'"]';
result.push({
key: [modifiedName],
data: $data[name]
});
}
// check if current name is an array
else if(_isArray($data[name])) {
// tell traverse next name is an array's index
var subArray = traverse($data[name],true);
result = result.concat(subArray.map(createMapHandler(modifiedName, $data)));
}
//check if current name is an object
else if(_isObject($data[name])) {
var subObject = traverse($data[name],false);
result = result.concat(subObject.map(createMapHandler(modifiedName, $data)));
}
}
return result;
};
var flatArray = traverse(structuredData,false);
var flatObj = {};
flatArray.every(function($item) {
//check for any dots followed by brackets and remove the dots
for(var i = 0;i<$item.key.length-1;i++){
var name = $item.key[i];
var nextName = $item.key[i+1];
if((/^\[/).test(nextName)){
$item.key[i] = name.replace(/\.$/,"");
}
}
//join all the keys in flatArray to form one key
flatObj[$item.key.join("")] = $item.data;
return true;
});
return flatObj;
};
var d = new DataObjectParser();
d.set("User.caravan.personel.leader","Travis");
d.set("User.caravan.personel.cook","Brent");
d.set("User.location.rooms[0]", "kitchen");
d.set("User.location.rooms[1]", "bathroom");
d.set("User.location.rowArr[0][0].Name", "Jun 00");
d.set("User.location.rowArr[0][0].Age", 19);
d.set("User.location.rowArr[0][1].Name", "Jun 01");
d.set("User.location.rowArr[0][1].Age", 20);
d.set("User.location.rowArr[1][0].Name", "Jun 10");
d.set("User.location.rowArr[1][0].Age", 21);
d.set("User.location.rowArr[1][1].Name", "Jun 11");
d.set("User.location.rowArr[1][1].Age", 22);
var obj1 = d.data();
console.log(obj1);
var flat = DataObjectParser.untranspose(obj1);
var obj2 = DataObjectParser.transpose(flat).data();
console.log(flat);
console.log(obj2);
// Reference:
// https://stackoverflow.com/questions/19098797/fastest-way-to-flatten-un-flatten-nested-json-objects
// https://stackoverflow.com/questions/24833379/why-and-when-do-we-need-to-flatten-json-objects
// https://stackoverflow.com/questions/7793811/convert-javascript-dot-notation-object-to-nested-object
// https://github.com/henrytseng/dataobject-parser
function unflatten(table) {
var result = {};
for (var path in table) {
var cursor = result, length = path.length, property = "", index = 0;
while (index < length) {
var char = path.charAt(index);
if (char === "[") {
var start = index + 1,
end = path.indexOf("]", start),
cursor = cursor[property] = cursor[property] || [],
property = path.slice(start, end),
index = end + 1;
} else {
var cursor = cursor[property] = cursor[property] || {},
start = char === "." ? index + 1 : index,
bracket = path.indexOf("[", start),
dot = path.indexOf(".", start);
if (bracket < 0 && dot < 0) var end = index = length;
else if (bracket < 0) var end = index = dot;
else if (dot < 0) var end = index = bracket;
else var end = index = bracket < dot ? bracket : dot;
var property = path.slice(start, end);
}
}
cursor[property] = table[path];
}
return result[""];
}
var flatten = (function (isArray, wrapped) {
return function (table) {
return reduce("", {}, table);
};
function reduce(path, accumulator, table) {
if (isArray(table)) {
var length = table.length;
if (length) {
var index = 0;
while (index < length) {
var property = path + "[" + index + "]", item = table[index++];
if (wrapped(item) !== item) accumulator[property] = item;
else reduce(property, accumulator, item);
}
} else accumulator[path] = table;
} else {
var empty = true;
if (path) {
for (var property in table) {
var item = table[property], property = path + "." + property, empty = false;
if (wrapped(item) !== item) accumulator[property] = item;
else reduce(property, accumulator, item);
}
} else {
for (var property in table) {
var item = table[property], empty = false;
if (wrapped(item) !== item) accumulator[property] = item;
else reduce(property, accumulator, item);
}
}
if (empty) accumulator[path] = table;
}
return accumulator;
}
}(Array.isArray, Object));
let obj1 = {
"User": {
"UserID": 999,
"Username": "Jun",
"IsEnabled": true,
"PermissionArr": {
"52": ["VIEW", "UPDATE"],
"53": ["VIEW", "UPDATE"],
"54": [{"Name": "View", "Status": true}, {"Name": "Create", "Status": false}],
},
"CreditCardArr": [
{"Num": "12345"},
{"Num": "6789"},
],
"RowArr": [
[{"Name": "Jun 00"}, {"Name": "Jun 01"}],
[{"Name": "Jun 10"}, {"Name": "Jun 11"}],
],
}
};
let data1 = flatten(obj1);
let obj2 = unflatten(data1);
//console.log(data1);
console.log(obj2);
<?php
require 'vendor/autoload.php';
use Symfony\Component\Serializer\Serializer;
use Symfony\Component\Serializer\Encoder\JsonEncoder;
use Symfony\Component\Serializer\Normalizer\ObjectNormalizer;
use Symfony\Component\Serializer\Normalizer\DateTimeNormalizer;
use Symfony\Component\PropertyInfo\Extractor\ReflectionExtractor;
$encoders = array(new JsonEncoder());
$normalizers = [
new ObjectNormalizer(null, null, null, new ReflectionExtractor()),
new DateTimeNormalizer(),
];
$serializer = new Serializer($normalizers, $encoders);
$person = new Person();
$person->setName('foo');
$person->setAge(99);
$person->setSportsman(false);
$jsonContent = $serializer->serialize($person, 'json');
$person2 = $serializer->deserialize($jsonContent, Person::class, 'json');
echo $jsonContent . PHP_EOL;
echo $person2->getName() . PHP_EOL;
// $jsonContent contains {"name":"foo","age":99,"sportsman":false}
//
// echo $jsonContent; // or return it in a Response
class Person
{
private $age;
private $name;
private $sportsman;
// Getters
public function getName()
{
return $this->name;
}
public function getAge()
{
return $this->age;
}
// Issers
public function isSportsman()
{
return $this->sportsman;
}
// Setters
public function setName($name)
{
$this->name = $name;
}
public function setAge($age)
{
$this->age = $age;
}
public function setSportsman($sportsman)
{
$this->sportsman = $sportsman;
}
}
syntax on
augroup vimrc_jun_todo
au!
au Syntax * syn match JunTodo /\v<(FIXME|NOTE|TODO|OPTIMIZE):/ containedin=.*Comment,vimCommentTitle
augroup END
hi def link JunTodo Todo
*.php linguist-vendored
*.css