barnettech / drupal8_book

4 stars 17 forks source link

Database needs to be reset before some chapters #4

Open iainhouston opened 8 years ago

iainhouston commented 8 years ago

It's really nice for the reader to be able to access the chapter-reliant source just by checking out a different branch. But ... After the reader has finished experimenting with the hello_world module the database needs to be set back to how it was before progressing to the next chapter and they checkout the new chapter's branch (and perhaps git clean -f as well)

This seems to be a remaining weakness with Drupal 8 where missing module (and theme?) code will cause fatal errors / WSODs. (It would be nice to think that Drupal's PHP "cache rebuild" would gracefully report on missing code.)

From the point of view of the book: An absolute beginner would be struggling to know why their web page went blank.

So ... would it be a good idea to show readers how to e.g.drush @drupal8vm.dev sql_dump > sql_dumps/dump.sql initially and then, before certain chapters: drush @drupal8vm.dev sqlc < sql_dumps/dump.sql

Zedda commented 8 years ago

I tried to empty my database and just killed my website with the error: "Symfony\Component\Routing\Exception\RouteNotFoundException: Route "system.404" does not exist"

I have been trying desperately to get my theme functions up and running with zero luck. I suppose I was about ready to do a clean install anyway.

barnettech commented 8 years ago

If after a clean install you can't get it working, post your code to a git repository, and I'll take a look to see help get it running if you like.

J

On Mon, Apr 4, 2016 at 4:29 PM, Zedda notifications@github.com wrote:

I tried to empty my database and just killed my website with the error: "Symfony\Component\Routing\Exception\RouteNotFoundException: Route "system.404" does not exist"

I have been trying desperately to get my theme functions up and running with zero luck. I suppose I was about ready to do a clean install anyway.

— You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub https://github.com/barnettech/drupal8_book/issues/4#issuecomment-205480583

Zedda commented 8 years ago

That would be lovely. I just did the clean install and I can't get it to go. I'll get it up on a git repo.

Zedda commented 8 years ago

https://github.com/Zedda/D8-Theming-Hell I'm obviously new to GitHub, I don't know how to parse everything into its separate folders, but there are the files.

barnettech commented 8 years ago

When I install your module, I can't bring up a page at /hello/world

It looks like you kept the name of the module name to be the same as the one in the book -- to be hello_world is this correct? Are you trying to bring up your own version of the page at the url /hello/world? What is your code trying to do?

On Mon, Apr 4, 2016 at 5:26 PM, Zedda notifications@github.com wrote:

https://github.com/Zedda/D8-Theming-Hell I'm obviously new to GitHub, I don't know how to parse everything into its separate folders, but there are the files.

— You are receiving this because you commented. Reply to this email directly or view it on GitHub https://github.com/barnettech/drupal8_book/issues/4#issuecomment-205503440

barnettech commented 8 years ago

Also there's no src directory and no controller directory within the src directory.

/hello_world/src /hello_world/src/controller

see https://github.com/barnettech/drupal8_book/tree/master/hello_world/src, you have missing folders and files, the controller directory houses this file which is the most important, it holds the code telling the system what to render on the /hello/world page https://github.com/barnettech/drupal8_book/blob/master/hello_world/src/Controller/HelloWorldController.php

On Mon, Apr 4, 2016 at 9:56 PM, James Barnett barnettech@gmail.com wrote:

When I install your module, I can't bring up a page at /hello/world

It looks like you kept the name of the module name to be the same as the one in the book -- to be hello_world is this correct? Are you trying to bring up your own version of the page at the url /hello/world? What is your code trying to do?

On Mon, Apr 4, 2016 at 5:26 PM, Zedda notifications@github.com wrote:

https://github.com/Zedda/D8-Theming-Hell I'm obviously new to GitHub, I don't know how to parse everything into its separate folders, but there are the files.

— You are receiving this because you commented. Reply to this email directly or view it on GitHub https://github.com/barnettech/drupal8_book/issues/4#issuecomment-205503440

Zedda commented 8 years ago

Thank you for looking at my files. I do indeed have everything located in its proper folders on my local test site. I am trying to reproduce the theme function part of the Theme Functions and Twig primer in the book. I have my Controller file in my src directory. I have your exact folder structure, I just don't quite know how to upload everything properly on GitHub yet.

My folder and structure goes:

hello_world (root) --js --css --src --Controller -HelloWorldController.php

-hello_world.info.yml -hello_world.module -hello_world.theme.inc

I have all of the files, folders, and the folder structure copied over exactly from the Git repo you mentioned.

Sent from my U.S. Cellular® Smartphone

-------- Original message -------- From: James Barnett notifications@github.com Date: 04/04/2016 9:01 PM (GMT-06:00) To: barnettech/drupal8_book drupal8_book@noreply.github.com Cc: Zedda rachel-flowers@live.com Subject: Re: [barnettech/drupal8_book] Database needs to be reset before some chapters (#4)

Also there's no src directory and no controller directory within the src directory.

/hello_world/src /hello_world/src/controller

see https://github.com/barnettech/drupal8_book/tree/master/hello_world/src, you have missing folders and files, the controller directory houses this file which is the most important, it holds the code telling the system what to render on the /hello/world page https://github.com/barnettech/drupal8_book/blob/master/hello_world/src/Controller/HelloWorldController.php

On Mon, Apr 4, 2016 at 9:56 PM, James Barnett barnettech@gmail.com wrote:

When I install your module, I can't bring up a page at /hello/world

It looks like you kept the name of the module name to be the same as the one in the book -- to be hello_world is this correct? Are you trying to bring up your own version of the page at the url /hello/world? What is your code trying to do?

On Mon, Apr 4, 2016 at 5:26 PM, Zedda notifications@github.com wrote:

https://github.com/Zedda/D8-Theming-Hell I'm obviously new to GitHub, I don't know how to parse everything into its separate folders, but there are the files.

— You are receiving this because you commented. Reply to this email directly or view it on GitHub https://github.com/barnettech/drupal8_book/issues/4#issuecomment-205503440

— You are receiving this because you commented. Reply to this email directly or view it on GitHubhttps://github.com/barnettech/drupal8_book/issues/4#issuecomment-205597992

Zedda commented 8 years ago

Now that I've properly uploaded my site through GitBash, here is the new repository:

https://github.com/Zedda/Theming

THAT may be a little easier for interpretation. I am trying to reproduce Figure 12-2 from the book. After a fashion, I tried giving up and just moving on to theming, but was unsuccessful. So here I am!

Zedda commented 8 years ago

I'm doing a little bit of poking around, and I noticed that on the HelloWorldController.php file, this code that I grabbed from the repo gives me the WSOD:

public function myCallbackMethod() { return array( '#theme' => 'hello_world_primary_page', '#items' => 100, ); }

So instead I have: public function myCallbackMethod() { $element = array( '#theme' => 'theme_hello_world_primary_page', '#items' => 100, ); return $element; }

This at least spits out my page instead of the WSOD, but it still does not call my theme function like in figure 12-2 of the book. I feel like I am getting warmer.

barnettech commented 8 years ago

are you able to switch cleanly to view the master branch version of the hello_world module and the with_theme_function version of hello_world directly checked out from my repository? Try that first. I found there was a huge caching problem, and at first the with_theme_function version didn't work right away.

On Tue, Apr 5, 2016 at 10:09 AM, Zedda notifications@github.com wrote:

I'm doing a little bit of poking around, and I noticed that on the HelloWorldController.php file, this code that I grabbed from the repo gives me the WSOD:

public function myCallbackMethod() { return array( '#theme' => 'hello_world_primary_page', '#items' => 100, ); }

So instead I have: public function myCallbackMethod() { $element = array( '#theme' => 'theme_hello_world_primary_page', '#items' => 100, ); return $element; }

This at least spits out my page instead of the WSOD, but it still does not call my theme function like in figure 12-2 of the book.

— You are receiving this because you commented. Reply to this email directly or view it on GitHub https://github.com/barnettech/drupal8_book/issues/4#issuecomment-205826092

barnettech commented 8 years ago

try clearing your cache at http://drupal8:8888/admin/config/development/performance I found I couldn't switch between the master branch version of hello_world and the with_theme_template version without clearing the cache. After doing this it worked fine.

On Mon, Apr 4, 2016 at 10:24 PM, Zedda notifications@github.com wrote:

Thank you for looking at my files. I do indeed have everything located in its proper folders on my local test site. I am trying to reproduce the theme function part of the Theme Functions and Twig primer in the book. I have my Controller file in my src directory. I have your exact folder structure, I just don't quite know how to upload everything properly on GitHub yet.

My folder and structure goes:

hello_world (root) --js --css --src --Controller -HelloWorldController.php

-hello_world.info.yml -hello_world.module -hello_world.theme.inc

I have all of the files, folders, and the folder structure copied over exactly from the Git repo you mentioned.

Sent from my U.S. Cellular® Smartphone

-------- Original message -------- From: James Barnett notifications@github.com Date: 04/04/2016 9:01 PM (GMT-06:00) To: barnettech/drupal8_book drupal8_book@noreply.github.com Cc: Zedda rachel-flowers@live.com Subject: Re: [barnettech/drupal8_book] Database needs to be reset before some chapters (#4)

Also there's no src directory and no controller directory within the src directory.

/hello_world/src /hello_world/src/controller

see https://github.com/barnettech/drupal8_book/tree/master/hello_world/src,

you have missing folders and files, the controller directory houses this file which is the most important, it holds the code telling the system what to render on the /hello/world page

https://github.com/barnettech/drupal8_book/blob/master/hello_world/src/Controller/HelloWorldController.php

On Mon, Apr 4, 2016 at 9:56 PM, James Barnett barnettech@gmail.com wrote:

When I install your module, I can't bring up a page at /hello/world

It looks like you kept the name of the module name to be the same as the one in the book -- to be hello_world is this correct? Are you trying to bring up your own version of the page at the url /hello/world? What is your code trying to do?

On Mon, Apr 4, 2016 at 5:26 PM, Zedda notifications@github.com wrote:

https://github.com/Zedda/D8-Theming-Hell I'm obviously new to GitHub, I don't know how to parse everything into its separate folders, but there are the files.

— You are receiving this because you commented. Reply to this email directly or view it on GitHub < https://github.com/barnettech/drupal8_book/issues/4#issuecomment-205503440>

— You are receiving this because you commented. Reply to this email directly or view it on GitHub< https://github.com/barnettech/drupal8_book/issues/4#issuecomment-205597992>

— You are receiving this because you commented. Reply to this email directly or view it on GitHub https://github.com/barnettech/drupal8_book/issues/4#issuecomment-205602720

Zedda commented 8 years ago

I've been using drush cr to clear the cache every time I make a change. Does this make a difference?

barnettech commented 8 years ago

Try clearing the cache at http://drupal8:8888/admin/config/development/performance, after doing this I was able to switch from the master branch to the with_theme_template version of hello_world. Clear the cache after checking out the branch of the code from github, that you would like to test out / view.

barnettech commented 8 years ago

It shouldn't, try from the url, just to be sure your drush is targeting the correct Drupal instance.

On Tue, Apr 5, 2016 at 12:40 PM, Zedda notifications@github.com wrote:

I've been using drush cr to clear the cache every time I make a change. Does this make a difference?

— You are receiving this because you commented. Reply to this email directly or view it on GitHub https://github.com/barnettech/drupal8_book/issues/4#issuecomment-205887801

Zedda commented 8 years ago

I'm running the with_theme_function branch and I'm getting the WSOD.

Zedda commented 8 years ago

In order to NOT get the WSOD, I had to change line 18 in my controller file: '#theme' => 'theme_hello_world_primary_page', to add "theme_", and I am STILL not getting the stuff from my theme function (fig 12-2 in the book). Do I need to set up a table in phpmyadmin?

barnettech commented 8 years ago

well I checked, and my code with theme function or with the theme template work. So you should just be able to take my module and change the guts of it, to display what you would like. Then you can just change the module name, but be wary you'll need to change the function names and folder name as well.

On Tue, Apr 5, 2016 at 1:48 PM, Zedda notifications@github.com wrote:

In order to NOT get the WSOD, I had to change line 18 in my controller file: '#theme' => 'theme_hello_world_primarypage', to add "theme", and I am STILL not getting the stuff from my theme function (fig 12-2 in the book). Do I need to set up a table in phpmyadmin?

— You are receiving this because you commented. Reply to this email directly or view it on GitHub https://github.com/barnettech/drupal8_book/issues/4#issuecomment-205917037

barnettech commented 8 years ago

if you go into your folder, do a git add . then a git commit . this will commit all files and folders for your new git repository, then I'll be able to see your code up at github to be more helpful.

Zedda commented 8 years ago

I may have found the source. What do you have in your custom hello_world table?

Zedda commented 8 years ago

I just pushed with_theme_function2 on my git

barnettech commented 8 years ago

I'm not sure what you mean?

On Tue, Apr 5, 2016 at 3:25 PM, Zedda notifications@github.com wrote:

I may have found the source. What do you have in your custom hello_world table?

— You are receiving this because you commented. Reply to this email directly or view it on GitHub https://github.com/barnettech/drupal8_book/issues/4#issuecomment-205957636

Zedda commented 8 years ago

I didn't actually have a hello_world table in my database. It makes sense that if we are calling data from a custom table that we would actually NEED that custom table in existence in our database. How is your hello_world table structured?

barnettech commented 8 years ago

You need to uninstall hello world then reinstall it, it will then be created for you.

Sent from my iPhone

On Apr 5, 2016, at 5:42 PM, Zedda notifications@github.com wrote:

I didn't actually have a hello_world table in my database. It makes sense that if we are calling data from a custom table that we would actually NEED that custom table in existence in our database. How is your hello_world table structured?

— You are receiving this because you commented. Reply to this email directly or view it on GitHub

Zedda commented 8 years ago

Perfect. Now I just need to populate it with some data to call (review chapter 11). I'll see you in a bit. Hopefully, the next post will be: "Yessssss! It's working, thank you!"

barnettech commented 8 years ago

Good 👍 I hope it's smooth sailing from here.

Sent from my iPhone

On Apr 6, 2016, at 9:40 AM, Zedda notifications@github.com wrote:

Perfect. Now I just need to populate it with some data to call (review chapter 11). I'll see you in a bit. Hopefully, the next post will be: "Yessssss! It's working, thank you!"

— You are receiving this because you commented. Reply to this email directly or view it on GitHub

Zedda commented 8 years ago

Thanks, I hope so! I have needed to focus on the instructional design aspect of my job this morning and haven't had a chance to get back to it yet, but I'm looking forward to saying: "YES! It's Working!" and then moving to Theming and Twig.

Zedda commented 8 years ago

@barnettech :+1: I did it!!! Of course, it helps if I CREATE the custom block, install it, enter data for the table to call, etc. (Basically pay attention to figure 12-1.)

theme_function_happy_dance

One thing: It would be really nice if this were spelled out somewhere. Maybe a README, a book update, etc. You wouldn't even have to spell out every step, just an: "If you're following along and want to reproduce what's in the book, you'll need to create this custom block with a form (you can find the code it on GitHub at __) and enter data for the table."

I tend to follow instructional material quite literally - and especially in this case where I have zero programming experience, that was a little bit of a leap.

THANK you, though. I feel like I can now move on!

barnettech commented 8 years ago

Glad it worked out :)

Sent from my iPhone

On Apr 6, 2016, at 6:13 PM, Zedda notifications@github.com wrote:

@barnettech
I did it!!! Of course, it helps if I CREATE the custom block, install it, enter data for the table to call, etc. (Basically pay attention to figure 12-1.)

One thing: It would be really nice if this were spelled out somewhere. Maybe a README, a book update, etc. You wouldn't even have to spell out every step, just an: "If you're following along and want to reproduce what's in the book, you'll need to create this custom block with a form (you can find the code it on GitHub at __) and enter data for the table."

I tend to follow instructional material quite literally - and especially in this case where I have zero programming experience, that was a little bit of a leap.

THANK you, though. I feel like I can now move on!

— You are receiving this because you were mentioned. Reply to this email directly or view it on GitHub