Categories
Laracast Series Notes Samuel

Notes from Laracast PHP series

php -v in gitbash shows version of php installed on the server

php -h shows a bunch of help options

php -S localhost:8888 (this starts a web server, similar to the php artisan server option)

sublime text is cheaper alternative to phpstorm (we might want to look at this once our phpstorm license expires)
atom is another editor Jeff likes and this open source, seems like a very cool program.

Categories
Fixing Stuff Laravel Samuel

Fixing Local Laravel Migration On Wamp 3.0.6

So We ran into an issue today when trying to migrate an old project on a newer version of wamp. The error we kept getting is:


[Illuminate\Database\QueryException]
SQLSTATE[42000]: Syntax error or access violation: 1067 Invalid default val
ue for 'created_at' (SQL: create table `marketing_sources` (`id` int unsign
ed not null auto_increment primary key, `name` varchar(100) not null, `note
s` text null, `created_at` timestamp default 0 not null, `updated_at` times
tamp default 0 not null) default character set utf8 collate utf8_unicode_ci
)

This error is caused by mysql not accepting a timestamp of 0 as the default set time. To fix this issue open up:

app > config > local-environment-folder > database.php

Then add the following line:
'strict' => true

*please note if you are using mysql then add this line to the mysql array.

Categories
Fixing Stuff Laravel Samuel

Laravel Local Environment Troubleshooting

Ran into this error today after setting up local environment:

The only supported ciphers are AES-128-CBC and AES-256-CBC with the correct key lengths.

Luckily there is a simple fix for this, documented below:

php artisan key:generate
*This will save an APP_KEY to your local .env file which will then be used to encrypt data.

Categories
Laravel Samuel

clean seeding laravel DB

in the .env file set clean seed to true:

IS_CLEAN_SEED=true

then migrate with seed:

php artisan migrate:refresh --seed

The clean seeds are defined in the DatabaseSeeder class. The MVC repo has examples.

Categories
Fixing Stuff Laravel Samuel

stop tracking changes to a file in Sourcetree

Came across an annoying issue the past couple times I tried pushing commits to the remote repo on a current project. My local machine has a “nesting” error when serving this project locally that that I wrote about fixing in a previous post. Well now the issue was when I went to commit some new code it wanted to commit the bootstrap auto loader file, which of course I did not want committed to the repo since this is only a problem on my local machine.

So step 1 opened the .gitignore file and added bootstrap/autoloader.php to it…… and nothing. Source tree still kept trying to force me to merge in the change to the file. I then tried “stop tracking this file” in source tree by right clicking on it and selecting the stop tracking option. Still nothing. So then tried restarting source tree, pulling down ect… all various things to try and get sourcetree to stop tracking the file to no avail. So finally went searching for a git command that would force sourcetree to ignore the file and came upon:

git update-index --assume-unchanged file.filename

To run this I simply opened up gitbash, which we covered installing on windows in a previous post. So open up gitbash, cd to boostrap, then run our handy new command: git update-index –assume-unchanged file.filename

Viola the next time I opened source tree the file was no longer hanging in the uncommitted changes :). If you were running into a similar issue hopefully this simple git command will help you out too!

—update—
If we need to stop tracking an entire directory use:

git rm -r --cached path_to_your_folder/

Categories
Fixing Stuff Laravel Samuel

laravel email error notes

troubleshooting a couple small laravel errors. First one = “belongs-to-many” database lookup error. It was from a view trying to show old data that was missing (IE we had a data set present, then half of it was deleted and the site did not gracefully degrade to still show the view). The fix for this was to just purge the rest of the data (it happened to be test data so that was fine). Now since a user can’t input incomplete data into the view the page should be good to go.

then we had a contact form timing out a “swiftmailer” error. We had the .env file on port 465 but needed 587, and then we noticed there were a couple things hard coded in config > mail.php that were from a previous project. We updated this mail file to the correct info, and also made the needed changes in the .env file so that in the future that file can quickly override the mail.php file for ease of updating.

BadMethodCallException] This cache store does not support tagging. Laravel file and database drivers doesn’t support tags.

to fix find the cache drive in .env file and update it to:
CACHE_DRIVER=array