How do you get PHP variable name (File) into AutoLisp/Visual Lisp? Is there any way other than web socket connection?
Related
staging\vendor\pusher\pusher-php-server\src\Pusher.php: 63
Pusher\Pusher::__construct(): Argument #2 ($secret) must be of type string, null given, called in \staging\vendor\laravel\framework\src\Illuminate\Broadcasting\BroadcastManager.php on line 302
I am using Vite and initializing Pusher as recommended per documentatins in my app.js compilation through Vite.
I'm trying to create a artisan command to dump data from database table in my existing Laravel 6 project.
I'm following the web to create the command, it works and prints out.
https://codeinphp.github.io/post/creating-your-own-artisan-in-php/
However I could not access the model in the existing project.
I've tried using
MyModel::all()
but it returns error about connection
PHP Fatal error: Uncaught Error: Call to a member function
connection() on null
I also tried do the data dump using existing getCsv() from controller, like
app('App\Http\Controllers\MyController')->getCsv();
Then it complains
Class request does not exist
I also tired doing
$table = DB::table('my_table');
But error returns as
A facade root has not been set
Using Laravel, I can get the client IP with request()->ip().
Is there a Laravel built-in way to get the server IP? Or is it something "impossible" (same problem as SERVER_ADDRreliability)
You can use request object:
request()->server('SERVER_ADDR');
Or you can use standard PHP way:
$_SERVER['SERVER_ADDR'];
Request::server('SERVER_ADDR') :)
URL Reference: https://laravel.com/api/5.3/Illuminate/Http/Request.html
$_SERVER['SERVER_ADDR']; for server ip
$_SERVER['SERVER_PORT']; for server port
You can use this way on the server.
$_SERVER['SERVER_ADDR'];
But you can not access SERVER_ADDR index locally. It will through Undefined index: SERVER_ADDR error. In my case, I face this error.
A better solution would be using variable from .env file which will work locally and server as well.
Defined a variable in .env file like this. You can give any name you want.
SERVER_ADDR = 127.0.0.1
Note: Please note SERVER_ADDR value should be 127.0.0.1 or localhost to get the server address value.
Now you can access this variable like this:
env('SERVER_ADDR');
If you are using IIS, you can only get the server IP using
$_SERVER['LOCAL_ADDR']
if it is LINUX, use :
$_SERVER['SERVER_ADDR'];
/** Server IP Check **/
if(!isset($_SERVER['SERVER_ADDR']){ $_SERVER['SERVER_ADDR'] = $_SERVER['LOCAL_ADDR']; }
/** Get Server IP **/
!isset($_SERVER['SERVER_ADDR']))?$_SERVER['LOCAL_ADDR']:$_SERVER['SERVER_ADDR']
This also gives you the IP
$request->ip();
I am trying to use Slack to post my debug messages to. i have followed some exmaple code and have this in my app.php file
$app->configureMonologUsing(function ($monolog) {
$monolog->pushHandler($chromeHandler = new \Monolog\Handler\ChromePHPHandler());
$chromeHandler->setFormatter(new \Monolog\Formatter\ChromePHPFormatter());
$slackHandler = new \Monolog\Handler\SlackHandler('xoxp-dasdasdzxczxcasdasdasdas', '#general');
$slackHandler->setLevel(\Monolog\Logger::INFO);
$slackHandler->setFormatter(new \Monolog\Formatter\LineFormatter());
$monolog->pushHandler($slackHandler);
});
which works and send mesages to slack using the following command
Log::info('thing to log');
I want to only send debug messages to slack if I am on a local machine.
I have tried reading in the the APP_ENV variable using env() but it is not returning anything.
I can access it using the same code in the controller. THerefore I assume it has not been loaded in the app.php file when I am trying to get it.
is there a better place to add the slack code, or anther way to detect the env variable?
In the production server with Beego I get
must have one register DataBase alias named default
I know the db connection credentials work in the server but whenever I do restful request I get this error and the Beego server crashes.
Is there a reason why this is happening?
Below is the code inside main.go init function:
orm.RegisterDriver("postgres", orm.DR_Postgres)
orm.RegisterDataBase("default", "postgres",
fmt.Sprintf("postgres://%s:%s#%s/%s?port=%i",
pgUser, pgPass, pgHost, pgDb, pgPort))
Can you provide a sample of your code?
Based on the error message you have provided, you may not have registered a database with alias default using orm.RegisterDataBase. Here's an example which I have taken from the documentation:
// param 1: Database alias. ORM will use it to switch database.
// param 2: driverName
// param 3: connection string
orm.RegisterDataBase("default", "mysql", "root:root#/orm_test?charset=utf8")
In beego, it is common to register the driver and the database in init of main.go (example).