Monthly archives: July, 2018

Force Laravel to Ignore errors

Force Laravel to Ignore database errors while running a laravel command line program as a demon service eg. $ php artisan extraction:analyze 3 > ./storage/logs/mqtt.log & try { $result = MqttMsg::create($data); } catch (\Exception $e) { $this->error(“ERROR CATCHED:”.$e->getMessage()); returnfalse; }

How to callback a function inside a class & use a 3rd class from vendor

use a 3rd class from vendor:  $mqtt = new \Bluerhinos\phpMQTT($server, $port, $client_id); callback a function inside a class: “function” => “proc_mqtt_msg”; to “function” => [$this,”proc_mqtt_msg”] $mqtt = new \Bluerhinos\phpMQTT($server, $port, $client_id); if(!$mqtt->connect(true, NULL, $username, $password)) { $this->error(‘Can not connect to mqtt server ‘.$server); exit(); } else { $this->error(‘Connected to mqtt server ‘.$server); } // listen to all …

VScode auto line wrap by default

In VS Code 1.9, we’ve changed the Toggle Word Wrap action to persist to User settings. The change was received with mixed feelings by our community, so for VS Code 1.10 we have rolled back that change and the action will only temporarily affect the current focused editor. The change also started a healthy discussion around the …

Add securityDefinitions Oauth2 to Swagger-PHP

Add securityDefinitions Oauth2 to Swagger-PHP / Infyom(AppBaseController.php) // “securityDefinitions”: { // “extraction_auth”: { // “type”: “oauth2”, // “tokenUrl”: “/oauth/token”, // “flow”: “password”, // “scopes”: [] // } // }, // “security”: [{“extraction_auth”:[] }],   // “securityDefinitions”: { // “extraction_auth”: { // “type”: “oauth2”, // “tokenUrl”: “/oauth/token”, // “flow”: “password”, // “scopes”: [] // } // …

Generate Swagger API Docs with Oauth2 Authorize from JSON file in a single HTML page

Use swagger-ui-bundle.js to generate Swagger API Docs with Oauth2 Authorize from JSON file in a single HTML page: <html> <head> <title>Swagger API Docs with Oauth2 Authorize</title> <linkrel=”stylesheet”href=”//unpkg.com/[email protected]/swagger-ui.css”> <scriptsrc=”//unpkg.com/[email protected]/swagger-ui-bundle.js”></script> <scriptsrc=”//unpkg.com/[email protected]/swagger-ui-standalone-preset.js”></script> <script> functionrender() { varui = SwaggerUIBundle({ url:`./swagger-api.json?a=1`, dom_id:’#swagger-ui’, deepLinking:true, presets: [ SwaggerUIBundle.presets.apis, SwaggerUIStandalonePreset ], plugins: [ SwaggerUIBundle.plugins.DownloadUrl ], //layout: “StandaloneLayout” }); } </script> </head> <bodyonload=”render()”> <divid=”swagger-ui”></div> …

Search parameters of L5-repository OR Infyom

Include 2 relationships: /api/v1/sites?limit=5&with=landowner;extractee https://github.com/andersao/l5-repository#using-the-requestcriteria Conducting research in the repository http://prettus.local/users?search=John%20Doe or http://prettus.local/users?search=John&searchFields=name:like or http://prettus.local/[email protected]&searchFields=email:= or http://prettus.local/users?search=name:John Doe;email:[email protected] or http://prettus.local/users?search=name:John;email:[email protected]&searchFields=name:like;email:= [ { “id”: 1, “name”: “John Doe”, “email”: “[email protected]”, “created_at”: “-0001-11-30 00:00:00”, “updated_at”: “-0001-11-30 00:00:00” } ] By default RequestCriteria makes its queries using the OR comparison operator for each query parameter.http://prettus.local/users?search=age:17;email:[email protected] The above example …

Generate models and migrations from exists database tables

https://github.com/krlove/eloquent-model-generator for generate models from exists POSTGRES database tables php artisan krlove:generate:model –output-path=Models –namespace=App\\Models Landowner don’t use plural for modle name. eg. use Landowner instead of landowners.   https://github.com/CrestApps/laravel-code-generator generator models, controller, view files, cool ! ! BUT NO API https://github.com/reliese/laravel for generate models from exists database tables https://github.com/Xethron/migrations-generator for Generate Laravel Migrations from an …

Install Laravel Docker for Mac

Install Laravel Docker for Mac 1. Download and install Docker for Mac, user: laraveldocker Pass:laravexxxxxxx.xxx8 2. Follow installation doc from http://laradock.io/documentation/ docker-compose up -d nginx postgres pgadmin redis workspace 3. errors fixed by “can add  shared paths /Applications/MAMP/htdocs/myapiary from Docker -> Preferences… -> File Sharing” and ERROR: for laradock_docker-in-docker_1  Cannot start service docker-in-docker: b’Mounts denied: …

How to use Json/jsonb in Postgres

How to use JSONB/Json in Postgres Now that we have gone over some of the benefits and use-cases for storing JSON data in Postgres, let’s take a look at how it’s actually done. Defining columns JSONB columns are just like any other data type now. Here’s an example of creating a cards table that stores …