String(4) "asas" is throen in the console while running artisan command laravel - laravel

I encountered a strange error today where the error looks like in the image:
I cloned my one of my colleague's repository and ran composer install command.
As it tried to generate optimized files, the error started popping out. After that, if I try to run any artisan command, it throws the same error text string(4) "asas".
To be more precise, I already have .env configured.
Please help. Am I really missing something that I need to look at?

The most likely explanation is that your colleague dumped asas somewhere in the code base. Probably in a place that is loaded everytime you execute a command, like a service provider.
Just search for asas in all files and you'll find something like:
dd('asas');
//or
var_dump('asas');
die;
Since asas is only the result, it may be a variable, like dd($test); where asas is the value.
If you don't find anything, search for dd or var_dump.

Related

go-swagger restapi/configure_todo_list.go - api.TodoGetHandler undefined error

I am a newbie in go and go-swagger. I am following steps in Simple Server tutorial in goswagger.io.
I am using Ubuntu 18.04, swagger v0.25.0 and go 1.15.6.
Following the same steps, there are a few differences of the files generated. For instance, goswagger.io's has find_todos_okbody.go and get_okbody.go in models but mine does not. Why is that so?
Link to screenshot of my generated files vs
Link to screenshot of generated files by swagger.io
Starting the server as written in the tutorial go install ./cmd/todo-list-server/ gives me the following error. Can anyone please help with this?
# my_folder/swagger-todo-list/restapi
restapi/configure_todo_list.go:41:8: api.TodosGetHandler undefined (type *operations.TodoListAPI has no field or method TodosGetHandler)
restapi/configure_todo_list.go:42:6: api.TodosGetHandler undefined (type *operations.TodoListAPI has no field or method TodosGetHandler)
The first step in goswagger.io todo-list is swagger init spec .... Which directory should I run this command in? I ran it in a newly created folder in my home directory. However, from the page, it shows the path to be ~/go/src/github.com/go-swagger/go-swagger/examples/tutorials/todo-list. I am not sure whether I should use go get ..., git clone ... or create those folders. Can someone advise me?
Thanks.
This is likely the documentation lagging behind the version of the code that you are running. As long as it compiles, the specific files the tool generates isn't so crucial.
This is a compilation error. When you do go install foo it will try to build the foo package as an executable and then move that to your GOPATH/bin directory. It seems that the generated code in restapi/configure_todo_list.go isn't correct for the operations code generated.
All you need to run this tutorial yourself is an empty directory and the swagger tool (not its source code). You run the commands from the root of this empty project. In order not to run into GOPATH problems I would initialise a module with go mod init todo-list-example before doing anything else.
Note that while the todo-list example code exists inside the go-swagger source, it's there just for documenting example usage and output.
What I would advice for #2 is to make sure you're using a properly released version of go-swagger, rather than installing from the latest commit (which happens when you just do a go get), as I have found that to be occasionally unstable.
Next, re-generate the entire server, but make sure you also regenerate restapi/configure_todo_list.go by passing --regenerate-configureapi to your swagger generate call. This file isn't always refreshed because you're meant to modify it to configure your app, and if you changed versions of the tool it may be different and incompatible.
If after that you still get the compilation error, it may be worth submitting a bug report at https://github.com/go-swagger/go-swagger/issues.
Thanks #EzequielMuns. The errors in #2 went away after I ran go get - u -f ./... as stated in
...
For this generation to compile you need to have some packages in your GOPATH:
* github.com/go-openapi/runtime
* github.com/jessevdk/go-flags
You can get these now with: go get -u -f ./...
I think it's an error of swagger code generation. You can do as folloing to fix this:
delete file configure_todo_list.go;
regenerate code.
# swagger generate server -A todo-list -f ./swagger.yml
Then, you can run command go install ./cmd/todo-list-server/, it will succeed.

Selenium WebDriverException: Reached error page

I am following a Django TDD tutorial at:
http://www.marinamele.com/taskbuster-django-tutorial/taskbuster-working-environment-and-start-django-project
I get the following error when running 'all_users.py' before and after I start the development server 'python manage.py runserver':
Traceback (most recent call last):
File "functional_tests/all_users.py", line 15, in test_it_worked
self.browser.get('http://localhost:8000')
File "/Users/samgao/.virtualenvs/tb_test/lib/python3.6/site->packages/selenium/webdriver/remote/webdriver.py", line 264, in get
self.execute(Command.GET, {'url': url})
File "/Users/samgao/.virtualenvs/tb_test/lib/python3.6/site->packages/selenium/webdriver/remote/webdriver.py", line 252, in execute
self.error_handler.check_response(response)
File "/Users/samgao/.virtualenvs/tb_test/lib/python3.6/site->packages/selenium/webdriver/remote/errorhandler.py", line 194, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: Reached error page: >about:neterror?e=connectionFailure&u=http%3A//localhost%3A8000/&c=UTF->8&f=regular&d=Firefox%20can%E2%80%99t%20establish%20a%20connection%20to%20the%20s>erver%20at%20localhost%3A8000.
Basically the connection to localhost cannot be established.
The settings and configurations are identical to the tutorial in the previous link.
I have been struggling with the issue for two days, and would thank you most kindly if you could provide any help.
I got the same error and what solved for me was changing from localhost to 127.0.0.1:
old: self.browser.get('http://localhost:8000')
better: self.browser.get('http://127.0.0.1:8000')
I encountered the same problem, the final solution is: re-install again geckodriver
Unzip the geckodriver.zip
Move the file to /usr/bin directory sudo mv geckodriver /usr/bin
Goto /usr/bin directory cd /usr/bin,then you would need to run something like sudo chmod a+x geckodriver to mark it executable.
this might not be your situation, but I got the same error message when running a test (same book, hehe) without having anything actually listening on the targeted port (8000, in my case). Make sure there's something listening for a request by manually opening your browser and going to localhost:8000. In my case - silly me - I didn't have the server up at all =)
I also followed the same tutorial and came across the same error. I noticed that I am not running the django server. The following is what helped.
python manage.py runserver
python functional_test.py
Being that this is a snapshot (around Django 1.8's time) of "Obey The Testing Goat" - perhaps the instructions there are no longer relevant. I suggest going straight to the goat's mouth and starting over!
The issue could be related to virtualenvwrapper (which is no longer necessary) or it could be related to the port/address that you were trying to access. Depending on your version of Selenium and Firefox there may be issues related to that as well.
It depends on the situation.
Based on mine, after I changed the target URL, I can get the browser to load the URL normally, which means the original URL is not available.
Another way to check:
import requests
html = request.get(url)
Print the HTML, if you get the 503, which means the website is reachable.
Since this is probably a common search result for those working through Obey the Testing Goat, I wanted to share the solution that worked for me. I had written self.browser.get('http://localhost:8000') and needed to use http instead of https to resolve the error.
I got this problem in this situation: the application put the computer name to the proxy host,so the proxy like this:
theComputerName:proxyPort
but the theComputerName:proxyPort can not be visit,so I put this into the host:
127.0.0.1 theComputerName
then restart the application,the problem resolved perfect
I learning TDD tutorial too. My problem was that inputed uncorrect url
http://http://mysite insted of http://mysite

Composer [UnexpectedValueException] error will trying to use composer to install a github project

I am trying to install a github project using composer and get the following error
Composer [UnexpectedValueException]
Your Github oauth token for github.com contains invalid characters: ""
Can anyone explain what I need to do to correct this error?
I am using the following command
composer create-project --prefer-dist --stability=dev vova07/yii2-start yii2-start
Thank you
I started getting a similar error and the reason was that Github recently changed the format of their auth tokens:
https://github.blog/changelog/2021-03-31-authentication-token-format-updates-are-generally-available/
To resolve the error:
Find the composer/auth.json file (if you're running the project in a container, you'll have to bash into it and find the file in there)
Remove its github.com entry. Your file will probably look like the following after removing the entry: {"github-oauth": {}}
Run composer self-update. The issue got resolved in version 2.0.12. See the first item in the changelog for that version here: https://getcomposer.org/changelog/2.0.12
After that, you can restore your composer/auth.json file to its initial state as the newer version of composer will recognize the new key format.
You can try Basic Auth instead:
Change this (oauth):
"github-oauth": {
"github.com": "ghp_[YOUR-PERSONAL-TOKEN]"
}
To this (basic auth):
"http-basic": {
"github.com": {
"username": "[YOUR-GITHUB-USERNAME]",
"password": "ghp_[YOUR-PERSONAL-TOKEN]"
}
}
You can find instructions on how to create a Personal Access Token
Inspired from github docs. Apparently, you can use Basic Authentication with a Personal Access token instead of oauth in some cases (e.g. like mine: installing a private git repo with composer).
I fixed it.
Goto C:\Users\XXXXX\AppData\Roaming\Composer
Open the auth.json
delete the github.com entry under "github-oauth": {}
That's it.
Update answer for Masiorama and Ruchir Mehta:
If you looking for file auth.json but don't know how, use this command:
locate auth.json
And here's the result:
You can see that auth.json will look like this:
/home/{your user name}/.config/composer/auth.json
Then you could use this command to edit the file:
sudo gedit /home/dev/.config/composer/auth.json
And remove content inside github-oauth.
If you're on MacOS, the auth.json file is at ~/.composer/auth.json. Then from there, you can remove the value for github-oauth. I tried fully deleting the file but I got a parse error, Expected one of: 'STRING', 'NUMBER', 'NULL', 'TRUE', 'FALSE', '{', '['. Your auth.json file should look like this:
{
"github-oauth": {}
}
This is similar to other answers posted but I wasn't able to use the locate command on MacOS so this might be helpful to other Mac users
This error recently popped up from nowhere.
Simply deleting the whole auth file worked for me..! Not sure why / when it appeared in the first place.
~/.composer/auth.json
As far as I know (I'm a beginner with composer too), the problem is with your authentication, so you have to fix your credentials in auth.json inside path-to-composer/.composer/
Inside you will find a json which will probably looks like:
{
"github-oauth": {
"github.com": null
}
}
Fix that and you should be ok ;)
The solution is just to upgrade your Composer version
using command composer self-update.
Go to C:\Users\UserName\AppData\Roaming\Composer
Open the auth.json file.
Clear everything and paste the below code
{
"bitbucket-oauth": {},
"github-oauth": {},
"gitlab-oauth": {},
"gitlab-token": {},
"http-basic": {},
"bearer": {}
}
I hope it will be solved
I run in the same problem after upgrading githup api token to the new format.
The answer is you need to upgrade composer version 1.10.21 or higher that fixes this problem.
Same solution as the answer of Paulina Khew but with command lines on MacOS :
cd ~/.composer/
nano auth.json
Delete what is inside th bracket :
{
"github-oauth": {}
}
When you're ready to save the file, hold down the Ctrl key and press the letter O
Press the Enter key on your keyboard to save.
When finished, press Ctrl + X to close nano and return to your shell.
Edit the composer authentication configuration file ~/.composer/auth.json
Then replace the following.
"http-basic": {
"github.com": {
"username": "[YOUR-GITHUB-USERNAME]",
"password": "ghp_[YOUR-PERSONAL-TOKEN]"
}
}
Now run the command composer install
That's a bug.
If you have Debian or Ubuntu, try this patch. Otherwise read the last line.
Quick copy-paste patch
If you have Debian 10 buster or Ubuntu 20.LTS or similar distributions, try this copy-paste command:
wget https://gist.githubusercontent.com/valerio-bozzolan/84364c28a3bba13751c504214016adcf/raw/c1356d529c89c10de4c959058e2e86ffe58fa407/fix-composer.patch -O /tmp/fix-composer.patch
sudo patch /usr/share/php/Composer/IO/BaseIO.php /tmp/fix-composer.patch
If it does not work, write it in the comments.
Step-by-step explaination
Your Composer version has a bug: you are able to save a valid GitHub token, but then it's not able to read that token again because Composer thinks that your GitHub token cannot contain underscores or stuff like that. Moreover, it's strange that Composer checks its syntax only the second time. Why? that's another story.
The fix is simple. You can temporary disable that wrong validation in your Composer version. Also because GitHub is a proprietary service and their specifications can change over time (as you demonstrated today). So it makes sense not to validate the syntax of GitHub tokens. The only person who should hard-validate GitHub tokens is GitHub itself, not Composer.
If you installed Composer via apt install composer, probably you will not have any update available and surely you cannot use self-update because Composer is read-only for security reasons (and for a similar reason, you should not execute Composer from root). Instead, you can create a safe hot-patch to fix that specific issue.
To create a patch, create a file called /tmp/fix-composer.patch with this exact content:
103,105c103,105
< if (!preg_match('{^[.a-z0-9]+$}', $token)) {
< throw new \UnexpectedValueException('Your github oauth token for '.$domain.' contains invalid characters: "'.$token.'"');
< }
---
> // if (!preg_match('{^[.a-z0-9]+$}', $token)) {
> // throw new \UnexpectedValueException('Your github oauth token for '.$domain.' contains invalid characters: "'.$token.'"');
> //
That content can also be seen from here:
https://gist.github.com/valerio-bozzolan/84364c28a3bba13751c504214016adcf
Then run this command to apply that patch:
sudo patch /usr/share/php/Composer/IO/BaseIO.php /tmp/fix-composer.patch
If it does not work, probably you have not installed composer via apt.
In short, whatever operating system, and whatever installation method, locate the file BaseIO.php in your Composer and comment out the validation check.

what is the difference between stensi & WanWizard datamaper versions?

I've tried stensi but I see it has some mistakes and unexpected output as mentioned in the user guide.
For example, when trying to delete a record it gives this error:
$p=new Per();
$p->where('id',1)->get();
$p->delete();
with an error message of:
undefined index id
when
echo $p->UserName;
outputs:
mhmd
and WanWizard has also this error:
<h4>A PHP Error was encountered</h4>
<p>Severity: Warning</p>
<p>Message: array_key_exists() expects parameter 2 to be array, boolean given</p>
<p>Filename: libraries/datamapper.php</p>
<p>Line Number: 399</p>
How can I overcome these errors or what can I do to make it work properly?
I've changed the two lines of code at ../libraries/datamapper.php line 399 (WanWizard version):
$d = array($this->config->item('datamapper'));
DataMapper::$config = $d;
and the error message disappeared.
If anyone has tried DataMapper and has a better suggestion, please let us know.
just found out this error can occur if you autoload the datamapper config file
Stensi's original version hasn't been maintained since 2007, and only supports CI 1.4. Not really an option anymore these days. It was forked by Overzealous in 2008, and I took over maintenance of that fork in 2010.
I fixed this (in the CI spark version) by moving the config file from the sparks directory to the /application/config directory.
There's something strange happening in CI v2.1.4 where
$this->config->load('datamapper', TRUE, TRUE);
on line 391 of application/libraries/datamapper.php in Datamapper-ORM v1.8.2.1 isn't "namespacing" the config correctly. If you do
print_r ($this->config); die;
just after line 391, you'll see all of the config values are in the general CodeIgniter "namespace" inside the loaded config array. The least intrusive way to get around this is to manually namespace your application/config/datamapper.php file yourself, by changing all the references from
$config['prefix'] = '';
$config['join_prefix'] = '';
...
to
$config['datamapper']['prefix'] = '';
$config['datamapper']['join_prefix'] = '';
...
That's how I got around it. Though #Mhmdgomma's fix does work, I prefer not to hack the core of the system when there is a simpler solution available. Someone should probably get the maintainers to fix this, but I'm not sure where the issue lies. It looks more like it's a CI issue, rather than DM.

Path Error running CakePHP's "cake" console utility in Windows

A while ago when I started with Cake, I managed to get the console running in my Windows environment, and I have no idea how. I'm now having problems to make it work again in another computer.
This is what I've done in the new machine:
Downloaded my Cake code from source control (so all the files are exactly the same as the computer where it worked, including the configuration files)
Added PHP and "c:\my_cake_path\cake\console" to the path
If I run "cake OneOfMyShells", either standing on the /app, or in /cake/console directories, I get the following error:
Warning: get_object_vars() expects parameter 1 to be object, null given in C:\my_cake_path\cake\libs\model\connection_manager.php on line 199
Error: Missing Database Connection. Try 'cake bake'
"cake Bake", if run normally, when I try to get it to do the DB config ends up throwing another error (which is not that relevant to this)
However, if I run: cake bake -app "c:\my_cake_path\app"
Then bake works, I can do the database config, and it writes the DB config file (which is useless at this point, since I already had one)
Then, of course: cake OneOfMyShells -app "c:\my_cake_path\app"
does work perfectly well.
So, everything's working fine, I just need to manually specify the path to "app" every single time, which is very annoying.
How can I get around this? Where is Cake looking for to find the path to app?
Thanks!
Daniel
Not much of a difference in the sense you still need to type but you can run cake from the app dir like this: C:\XXX\project\app> ..\cake\console\cake.bat
To make it smaller you can put that line on a .bat or just add the \cake\console dir the windows path

Resources