TheFriendlyHacker

TheFriendlyHacker

Member Since 3 Years Ago

Athens, GA

Experience Points 27,810
Experience Level 6

2,190 experience to go until the next level!

In case you were wondering, you earn Laracasts experience when you:

  • Complete a lesson — 100pts
  • Create a forum thread — 50pts
  • Reply to a thread — 10pts
  • Leave a reply that is liked — 50pts
  • Receive a "Best Reply" award — 500pts
Lessons Completed 197
Lessons
Completed
Best Reply Awards 3
Best Reply
Awards
  • start-engines Created with Sketch.

    Start Your Engines

    Earned once you have completed your first Laracasts lesson.

  • first-thousand Created with Sketch.

    First Thousand

    Earned once you have earned your first 1000 experience points.

  • 1-year Created with Sketch.

    One Year Member

    Earned when you have been with Laracasts for 1 year.

  • 2-years Created with Sketch.

    Two Year Member

    Earned when you have been with Laracasts for 2 years.

  • 3-years Created with Sketch.

    Three Year Member

    Earned when you have been with Laracasts for 3 years.

  • 4-years Created with Sketch.

    Four Year Member

    Earned when you have been with Laracasts for 4 years.

  • 5-years Created with Sketch.

    Five Year Member

    Earned when you have been with Laracasts for 5 years.

  • school-session Created with Sketch.

    School In Session

    Earned when at least one Laracasts series has been fully completed.

  • welcome-newcomer Created with Sketch.

    Welcome To The Community

    Earned after your first post on the Laracasts forum.

  • full-time-student Created with Sketch.

    Full Time Learner

    Earned once 100 Laracasts lessons have been completed.

  • pay-it-forward Created with Sketch.

    Pay It Forward

    Earned once you receive your first "Best Reply" award on the Laracasts forum.

  • subscriber-token Created with Sketch.

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • lifer-token Created with Sketch.

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • lara-evanghelist Created with Sketch.

    Laracasts Evangelist

    Earned if you share a link to Laracasts on social media. Please email [email protected] with your username and post URL to be awarded this badge.

  • chatty-cathy Created with Sketch.

    Chatty Cathy

    Earned once you have achieved 500 forum replies.

  • lara-veteran Created with Sketch.

    Laracasts Veteran

    Earned once your experience points passes 100,000.

  • 10k-strong Created with Sketch.

    Ten Thousand Strong

    Earned once your experience points hits 10,000.

  • lara-master Created with Sketch.

    Laracasts Master

    Earned once 1000 Laracasts lessons have been completed.

  • laracasts-tutor Created with Sketch.

    Laracasts Tutor

    Earned once your "Best Reply" award count is 100 or more.

  • laracasts-sensei Created with Sketch.

    Laracasts Sensei

    Earned once your experience points passes 1 million.

  • top-50 Created with Sketch.

    Top 50

    Earned once your experience points ranks in the top 50 of all Laracasts users.

04 Aug
1 year ago

TheFriendlyHacker left a reply on Checking If Server (IP) Is Offline, And Some Issues I've Encountered

I've found an acceptable solution for my needs (StackExchange to the rescue!).

Curl does the trick:

$ch = curl_init($host);
curl_setopt($ch, CURLOPT_TIMEOUT, 5);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$data = curl_exec($ch);
$httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
if($httpcode !== 0){
  // Do stuff for the server being online
} else {
  // Do stuff for the server being offline
}

Note: In this case, I'm just checking to see if any HTTP code is returned at all (aka, not 0). Some may prefer to see what specific HTTP code is received (eg, they want to make sure they're getting a 200 or something). In that case, it is quite easy to modify for those needs. For example,

if($httpcode >= 400){
  // Do something for a 400/500 error
} else {
  // Do something for a 200/300 response
}

But in terms of telling whether or not the server is online, this is perfect!

29 Jul
1 year ago

TheFriendlyHacker left a reply on Checking If Server (IP) Is Offline, And Some Issues I've Encountered

Interesting update: I just tested out this PHP script on my Mac locally:

https://github.com/avignat/Check-Server-Status

So I have two servers (let's refer to them as "server1" and "server2"). I have shut down server1, and left server2 online.

Based on that script's source code, it runs fsockopen, using port 80.

When I ping server1's IP address (as in, its actual IP address, not the CloudFlare IP), I get all timeouts (100% packet loss), and I can't SSH into it. But that aforementioned PHP script shows it as online (which is incorrect - that server is definitely offline).

When pinging server2, I get a response, and it also shows as online on that aforementioned PHP script (which is correct).

When I give that PHP script a completely bogus hostname/IP address (for example "asfasfasfsaf.net"), it shows it as offline (which is correct - that host doesn't exist)

Both of my servers are Linux VPS's. I'm wondering if my VPS host could have some sort of configuration on their network that is messing up all of tests I've attempted.

TheFriendlyHacker left a reply on Checking If Server (IP) Is Offline, And Some Issues I've Encountered

I am developing the Laravel app on my Macbook (via Valet), and this is where I am not getting any output from the exec command.

From the same MacBook, I can ping the server from the terminal and get a response ping insert.my.server.ip

Additionally, I have tried pinging it from the command line on another server, and was also able to get a response.

I'm wondering if either a): I'm using the exec command incorrectly (perhaps there's a different way to get output?)

b): There is a permission issue with php on my MacBook. I have chmod'd the entire Laravel app to 777.

TheFriendlyHacker left a reply on Checking If Server (IP) Is Offline, And Some Issues I've Encountered

@Cronix I can ping them for sure (when I do so from the Terminal on my Mac, I do get a response).

As for your suggestion, that is definitely a possible option. My only concern: I plan on including the ability in my application to add new servers to monitor from the user interface (eg, you'd enter the server's IP and a name for it, and it'll start monitoring it).

Is there a somewhat-easy way to implement something like this going off of your suggestion? Especially since ~75% of the web URL's on my servers would be going through CloudFlare, which will probably return some sort of response even if the original server is down.

TheFriendlyHacker started a new conversation Checking If Server (IP) Is Offline, And Some Issues I've Encountered

I am trying to build a simple Laravel application that will periodically check if a couple of servers are online or offline. I am satisfied with simply pinging the IP address of each server.

I am currently running PHP 7.2 on OS X (using Laravel Valet).

I'm thinking I could use the exec function to ping the IP and then check the output. However, whenever I try to var_dump or dd the output from the exec, I get an empty string.

Below is my code (may or may not be from StackExchange haha):

$ip = "my.server.ip.address";
$ping = exec("ping -c 1 -s 64 -t 64 ".$ip);

dd($ping);

I have also tried this to no avail:

$ip = "my.server.ip.address";
$ping = exec("ping -c 1 -s 64 -t 64 ".$ip, $output);

dd($output);

Any ideas why I might not be getting any output?

21 May
1 year ago

TheFriendlyHacker left a reply on Allowed Memory Size Exceeded...

@bwrice Heh. Sometimes the tiniest things hold you up. Thanks for pointing that out!

20 May
1 year ago

TheFriendlyHacker left a reply on Allowed Memory Size Exceeded...

There's not a whole lot to see yet haha. And I haven't messed with my user model a whole lot (aka, there wouldn't be anything out of the norm that would cause problems when creating users).

Here we go:

// DatabaseSeeder.php 
public function run()
{
    $this->run(UserSeeder::class);
    $this->run(PolicySeeder::class);
}
// UserSeeder.php
public function run()
{
    DB::disableQueryLog();

  // Admin
  User::create([
    'name' => 'Admin User',
    'email' => '[email protected]',
    'password' => bcrypt('secret')
  ]);

  // Normal User
  User::create([
    'name' => 'Normal User',
    'email' => '[email protected]',
    'password' => bcrypt('secret')
  ]);

  // Denied User
  User::create([
    'name' => 'Denied User',
    'email' => '[email protected]',
    'password' => bcrypt('secret')
  ]);
}

It never makes it past the UserSeeder, even when I comment out all of the code in the "run" method. Tried doing the same for PolicySeeder, same result.

TheFriendlyHacker left a reply on Allowed Memory Size Exceeded...

@Cronix The seeder is running 3 writes (creating 3 users with just a name, email and password). I'll disable logging and see if anything changes, but it seems a bit odd either way for just 3 small queries haha.

I have another Laravel project running in the same environment (I believe it's Laravel 5.5), and it's able to seed a lot more data without any issues.

Think it could be a bug in a recent update to 5.6?

Update: Tried disabling query logging with no luck - still getting the same error.

TheFriendlyHacker started a new conversation Allowed Memory Size Exceeded...

I am trying to run some seeders on a local MariaDB database (on a Mac). memory_limit for PHP is set to 256M. When running the seeder, I get this error message:

PHP Fatal error:  Allowed memory size of 134217728 bytes exhausted (tried to allocate 262144 bytes) in Unknown on line 0

I tried commenting out all of the code in my seeder's run method just to see if it would continue throwing the error - it did.

Do you guys have any ideas what might be causing this?

19 May
1 year ago

TheFriendlyHacker left a reply on Free Plan In Spark Without Requiring A Credit Card

@topvillas I suppose I could. But is that really the best / only way?

TheFriendlyHacker started a new conversation Free Plan In Spark Without Requiring A Credit Card

I want my Spark application to offer a free plan that users will be "subscribed" to by default. Not a trial (aka, so no expiration), and I do not want to require payment information up front.

If users want to have access to "premium" features of the application, they may choose to subscribe to a paid plan.

Does anybody know how to implement something like this?

07 Apr
1 year ago

TheFriendlyHacker left a reply on Issues With Laravel Spark Installer

@ejdelmonico Thanks for the heads up! I will try manually running NPM and see if that works.

And yes, everything was installed via Homebrew.

TheFriendlyHacker left a reply on Issues With Laravel Spark Installer

@ejdelmonico I have a directory on my Mac that I put all of my projects into. With previous versions of Spark (<= 5.x.x), running spark new ProjectName would generate a new Spark project without any issues.

I'm not installing Spark into an existing Laravel project, if that is what you're asking.

TheFriendlyHacker started a new conversation Issues With Laravel Spark Installer

I recently purchased a license for Spark 6.0 and installed the latest version of the spark-installer.

When I try to create a new Spark project spark new ProjectName --braintree --team-billing I get some errors when trying to install and compile NPN dependencies.

The first error occurs when trying to install NPM stuff:

dyld: Library not loaded: /usr/local/opt/icu4c/lib/libicui18n.60.dylib
  Referenced from: /usr/local/bin/node
  Reason: image not found
sh: line 1: 33560 Abort trap: 6           npm set progress=false

The second one occurs when trying to compile the assets:

The process has been signaled with signal "6".

Has anybody else encountered this, and/or does anybody know how to work around it?

My local machine is running PHP 7.2

Thank you!

TheFriendlyHacker started a new conversation Optional But Unique Field Validation

Hello,

My application gives users the ability to add their phone numbers if desired, however, they are not required to do so. If a user does choose to enter their phone number, I would like to validate it for uniqueness.

My question is: how do I do that with Laravel's validator? If a user enters an empty value for the phone number, the validator will catch that as being non-unique, since other users will have done the same.

26 Jan
1 year ago

TheFriendlyHacker started a new conversation Somewhat Niche Question About Redis

I'm building a URL shortener application, and I want to provide daily click analytics for each link (e.g. link a was clicked 43 times on Jan. 25, 22 times on Jan 26 and 0 times on Jan 27).

Redis seems like a pretty good solution for this. I'm thinking I could store daily link clicks with keys structured like "link-[link id].[date]" (eg link-1.01-25-2018).

However, let's assume there are tens (or hundreds) of thousands of links, each one needing to have its clicks tracked every day. I am wondering how quickly RAM usage would become a problem, especially after a few months of tracking many thousands of links.

What are your thoughts?

20 Jan
1 year ago

TheFriendlyHacker started a new conversation Best Way To Track Link Clicks

I am building a URL shortener application (mainly to learn/better some skills with this type of development).

I was wondering, what would be the best way to keep track of clicks that each shortened link gets? Mainly for the purpose of generating reports on daily/monthly/etc link clicks.

The first (and easiest) solution that comes to mind is to save each click as a database record, with a timestamp, referral url, etc. But this seems like it might be too much for the database (theoretically, this would mean that my "clicks" table receives quite a number of writes per second).

What solutions would you recommend for this situation? And/or, do you think the database would be able to handle such a potentially high amount of traffic?

Thanks in advance!

17 Jan
1 year ago

TheFriendlyHacker started a new conversation Curious About Server Specs

I have a VPS server w/ 4GB of RAM, 2 "vcores" (Intel E3) and 300GB of HDD storage.

I was wondering how I can gage this server's ability to run a MySQL/MariaDB database with very frequent writes and tables with potentially millions of records.

Does anybody have any experience with this, and/or have any pointers to some resources that could help me get a feel for the capabilities of certain specs in terms of running a database server?

Thanks in advance!

07 Jan
1 year ago

TheFriendlyHacker started a new conversation JSHint Not Working For .vue Files In Sublime Text 3

Hello,

I have SublimeLinter + JSHhint set up, and it works perfectly with .js files. However, how would I get it to lint .vue files in the same way? I had it working in the past, but have long since forgotten how I did it.

Thanks in advance!

26 Dec
1 year ago

TheFriendlyHacker left a reply on Best Practice For Queues

@shez1983 What specifically do you mean? Should each job process all of the songs that the user uploaded, or should there be a separate job for each song?

23 Dec
1 year ago

TheFriendlyHacker started a new conversation Best Practice For Queues

Hello,

I have a somewhat niche question regarding how to handle a queued task.

My application will allow users to upload songs (multiple songs at the same time). Once uploaded, there will be a queued task that retrieves the ID3 info + cover art from each song (cover art is retrieved via an external API...so, a few HTTP requests on the back-end).

My question is, let's say a user uploads 5 songs. Should I push each song job to the queue individually (aka, each song = 1 separate task on the queue, resulting in 5 jobs being pushed), or should I group all of them together into a single job?

Thanks

09 Dec
1 year ago

TheFriendlyHacker started a new conversation Redis Vs Amazon SQS For Queue

Hello,

I am trying to choose a queue driver for my application. The jobs it will be processing won't be super complex/resource-intensive. Mainly gathering information about audio files a user uploads.

EX: A user uploads a song. A job would be queued that does the following:

  • gathers the id3 info about the song (trivial in terms of resources)
  • fetched cover/album art for the song (requires some HTTP requests to an external API)

I am caught between using Redis on a separate server vs using Amazon SQS. So far, I am favoring SQS due to its relative ease of use and robustness. But I want to hear some of your opinions, including recommendations for drivers other than Redis or SQS, if you think they would be better.

Thanks!

26 Nov
1 year ago

TheFriendlyHacker left a reply on Redis Queue On A Different Server

@haganjones That definitely helps!

So, if I am interpreting what you said correctly, I would need to install my Laravel application on both servers, correct?

Also, thanks for pointing me to Laravel Horizon! I wasn't even aware of it until now!

TheFriendlyHacker started a new conversation Redis Queue On A Different Server

I have two VPS servers. I plan on hosting the app on one of them, and using the other one to process large queued jobs via Redis.

My main question is, do I need to install my Laravel app on both servers, or just on the main one that will be hosting the application?

Thanks!

19 Nov
1 year ago

TheFriendlyHacker started a new conversation Streaming Audio From S3

I am building an application that allows users to listen to music using S3 to store all of the files. I am relatively new to streaming.

I know you can use S3 or CloudFront to create a signed URL and stream directly from S3 to the client, but I do not want to do that if at all possible (signed URL's have an expiration. If somebody were to share a signed url before it expires, then others could access the resource).

So my question is, what are some ways to efficiently/quickly stream music from S3 > my PHP application > Client? I have tried a couple of different approaches, all of which are quite slow (lots of buffering, or the entire audio file is loaded at once, creating 5-10 second load times).

07 Nov
1 year ago

TheFriendlyHacker started a new conversation Ordering Many-to-many Relations

I want my users to be able to create playlists of songs. Currently, I have a many-to-many relationship between playlists and songs. When creating a playlist, the user will likely want to specify the order in which the songs will play (I'm thinking an integer column that represents the song's order in the playlist).

What would be the best way to accomplish this, since I can't specify the order in the songs table (as each song can belong to multiple playlists)?

01 Nov
1 year ago

TheFriendlyHacker started a new conversation Spark: Allow Users To Subscribe To Free Plan Without Entering Credit Card Info

Hello!

I would like my users to be able to subscribe to a free plan while registering, without requiring them to enter their credit card info.

Basically, they only have to enter their info once they decide to subscribe to a paid plan.

How do / can you do this with Spark?

I know you can set up trials that do not require cards up front, but I would rather them be able to subscribe to a "permanent" free plan instead.

Thanks!

28 Oct
1 year ago

TheFriendlyHacker left a reply on Best Way To Stream Video In Laravel

@topvillas I understand. However, I would still like to learn how it works and build some implementations of my own.

TheFriendlyHacker started a new conversation Best Way To Stream Video In Laravel

I am relatively new to the world of streaming videos from PHP. I am wondering what, in Laravel, is the best way to start a video stream. Obviously, I wouldn't want to just send an entire video all at once, since that would take an incredibly long time to load.

Could I get some tips/pointers to help me get stated?

08 Sep
1 year ago

TheFriendlyHacker left a reply on Laravel Multi-language Website With Different Domains

My first thoughts are to host a single instance of the application, but set the locale at run time, based on the domain.

$domain = url('/');

if($domain === 'english.domain') {
  config(['app.locale' => 'en']);
} else {
  config(['app.locale' => 'fr']);
}

Something along those lines.

TheFriendlyHacker left a reply on When To Use A Repository

Repositories aren't always necessary, but they do have their purpose. The main reasons I'd use them are

  1. to allow for DRYer code (more on that in a second)
  2. in case you switch model drivers, that way you don't have to rewrite all of your controller code

Going back to DRYer code, let's say you have a fairly complex query that you'll be using in multiple instances/routes throughout the application.

Normally, you'd bring in your models and type out the entire query each time you need to use it. And this can be bothersome when you must do so several times throughout the application. And on top of that, if you decide that you want to change the query, you have to traverse through your entire application, modifying the query code in a bunch of different places.

Now let's say you use a repository class, and create a method called 'someComplexQuery', which runs this complex query. Throughout your application, each time you need to use this query, you simply need to bring in your repository and call the 'someComplexQuery' method. A single line of code vs many, many lines. And if you want to change/modify the query, you'll simply have to do so one time, in your repository class vs having to track down and manually change the query in multiple files throughout.

I did previously mention that repositories aren't always necessary, though. And, personally, the only time I wouldn't make use of them is if my application is quite small and will only be running short, simple queries throughout.

Hopefully this helps clear things up :)

TheFriendlyHacker left a reply on Best Way To Record Video Views

@martinbean That is a very valid point you bring up! I suppose there should be some logic involved in determining which views are valid.

In the case of our application, we probably won't pay creators based on view/seconds watched count (at least not as of now), but rather go the YouTube route with advertisements.

As for your case, perhaps it would be a good idea to include columns for 'seconds_watched', and maybe even 'percentage_of_video_viewed' ( / ), and calculate those when the view record is created, in addition to start and end times. My main thinking behind this is to make it easier to query "valid" views. E.G., if you only want to count views in which at least 30% of the video was watched, and/or at least 30 seconds were viewed. Having data like that readily available would make querying a bit easier and faster.

Just my two cents though, I'm far from an expert on this!

TheFriendlyHacker started a new conversation Best Way To Record Video Views

I am building a video website (somewhat similar to YouTube). I was wondering what would be the most efficient way to record views on videos, in order to display a view count and to provide the creator with statistics on daily views.

My first thoughts are to create a 'views' table, with relationships to a video and a user. Assuming the worst case scenario (there are tens of millions of views recorded), would this still be a valid option?

27 Aug
1 year ago

TheFriendlyHacker started a new conversation Polymorphic Relationship For Followers/subscribers

I am building a simplified, Reddit-esque social media application. Similarly to Reddit, users will be able to "follow"/"subscribe" to each other as well as to groups (equivalent of "sub-reddits").

I am thinking that I should create a many-to-many polymorphic relationship for followers. The "followable_type" will either be a user or a group.

My question is, I don't think it is necessary to create a "Follower" model (because followers are just users). Is there a way to accomplish this without the need to create a separate model for Followers?

07 Aug
2 years ago

TheFriendlyHacker started a new conversation How To Store Options/settings In The Database

My application will allow users to create posts. Posts will have certain settings that the user will be able to customize (e.g. "allow comments", "allow likes", "show author name", etc).

Should each of these options be stored as a separate column in the "posts" table (e.g. have columns like "allow_comments", "allow_likes", etc), or is there a better way to handle this?

13 Jun
2 years ago

TheFriendlyHacker started a new conversation Best Way To Count Unique Views On A Blog Post?

I'm building a blog site, and I'd like to keep track of how many unique people have viewed each post. Emphasis on "how many unique people". In other words, if one person reads the same blog post 10 times, I only want it to be counted as 1 view. But if 10 different people read the post, that would be counted as 10 views.

What would suggestions do you have? I'm thinking I can store a cookie on each client's browser when they access the website, which would serve to identify them. But what would be the best way to implement this?

09 Jun
2 years ago

TheFriendlyHacker left a reply on Set A Default Value When Asking For Input In An Artisan Command...

I actually found the answer here https://stackoverflow.com/questions/34772764/laravel-console-command-ask-for-a-non-required-optional-input

It turns out that the ask method accepts a second argument as a default value if nothing is entered.

$this->ask('Please enter your database host [127.0.0.1]', '127.0.0.1');

TheFriendlyHacker started a new conversation Set A Default Value When Asking For Input In An Artisan Command...

With the artisan console, you can prompt the user for input via $this->ask('Please enter something');

I am trying to create an installation command that walks the user through configuring their database connection as well as an admin account. In some cases, I want to use a default value if the user does not enter anything.

For example, when asked to enter the host for their database, I want a default value of '127.0.0.1' if the user does not enter anything. $this->ask('Please enter your database host [127.0.0.1]'); // defaults to '127.0.0.1' if nothing is entered

Is there a way to do this?

07 Jun
2 years ago

TheFriendlyHacker started a new conversation Can You Hide Overflow On An <img> Tag?

I am allowing users to upload thumbnail images for posts they make. In order to comply with the site's layout, the images have to be about 450px x 225px.

Obviously, I wouldn't want to limit users to only being able to upload images with those exact dimensions. And I don't want to just resize the images to those dimensions, because it will distort them.

Is it possible to set an img tag to hide any overflow? That way, if someone uploads an image that is 600x300px, it will "crop" it?

16 May
2 years ago

TheFriendlyHacker started a new conversation Why Isn't JQuery AJAX Used In Place Of Things Like Vue-resource Or Axios?

I'm asking this mostly out of curiosity. Most applications will make use of jQuery, which includes a seemingly through AJAX feature. It's a fairly large library as well, contributing a lot to your main script's size. Why do a lot of developers choose to bring in a separate library like Axios instead of using jQuery?

03 May
2 years ago

TheFriendlyHacker started a new conversation Strange Problem With Vue-Router

I am using Vue.js + vue-router to build a basic social media SPA. So far, I have two pages/routes. The first one is a "feed" page that displays an overall listing of posts users have made. The second page is for when a user clicks on a post, and more details are displayed.

I have a button in the navigation bar - which is common to all pages - which refreshes the feed/post currently being viewed. It does so by using a Vue event bus to emit a 'page-was-refreshed' event.

So here's the problem: if a user clicks on a single post, the component will keep listening for the 'page-was-refreshed' event, even if they navigate away from it. And this keeps building up...so if they have viewed 3 posts, then all three of the components will somehow still be listening for that event, even though the user has since navigated away.

What do you think could be going on here, and how do I stop it from happening?

18 Apr
2 years ago

TheFriendlyHacker started a new conversation Somewhat Odd Question About Storing Relationships...

I am building a site that offers smartphone repair services. Users can fill out a form with some info about their device (e.g., model, manufacturer, color, etc), and submit it for a price quote.

Many smartphones come in a variety of colors (e.g., an iPhone can be black, white, pink, etc), so for each device in the database, I have a column called "colors" which stores an array of colors e.g. ["black", "silver", "white"].

My quotes table contains a relationship for the devices table ('device_id'). But I need to specifically know what color the quoted device is (e.g. "white iPhone 6s"). My current setup is not able to do this.

What do you think is the best way to go about associating not only a smartphone, but a specific color of a smartphone, with a quote? I don't necessarily want to create a separate entry in the devices table for each color variant.

10 Apr
2 years ago

TheFriendlyHacker started a new conversation Where To Store A Lot Of Static Data?

Short background: I am working with a client who organizes lectures/conferences for audiences. The site I am building will be responsible for displaying information about these conferences as well as selling tickets for them.

TL;DR

I have a lot of semi-static data that needs to be displayed on a site (I say "semi-static" because it does not dynamically change based on the state of the application, but rather, it is manually updated whenever a change is needed). The client does not want to use a database to store this data, so I am currently organizing it into JSON files, and retrieving it when the corresponding page is loaded. I'm on shared hosting, so I don't have access to many "special" things other than MySQL (so no Redis or Memecached or SQLite, etc). What recommendations do you have? Do you think I'm doing it right? Do you know of a better way?

I have the ticket-selling part well under control. However, I do have a few questions about best practices for storing/displaying mostly static data on a Laravel app.

I say "mostly" static because, while this data does not change very often, it is changed up to a couple of times per month.

Some examples of this data includes:

  • Lists of upcoming conferences (basically an HTML table with a name, location and purchase link for each conference)
  • Lists of companies who are sponsoring each conference
  • Basically everything else follows a similar structure: a predictable list of entities that will be displayed on the site.

I don't necessarily want to store this information in the database (mainly because the client requested that I not do so...for some reason). So right now, I've created some JSON files in my application that contain all of the "static" data that will appear throughout the site. I've separated different "entites" into different JSON files as well (for example, on a page that display information for a specific conference, I will have one JSON file containing a list of people who will be speaking at the conference, another for companies that have sponsored the conference, one containing a schedule, etc).

How would you go about storing data like this on a website? I know I could always "hard code" the data into my views...but I really don't want to do that. I prefer having all of the data be stored outside of the view (as does the other guy who is helping me work on this project). Additionally, the site is on a shared hosting account...so I won't be able to make use of anything too fancy, such as SQLite, redis, etc.

And recommendations?

TheFriendlyHacker started a new conversation Is Redis Safe?

I'm fairly new to Redis. Basically, I understand that Redis is an in-memory database of sorts, and it's quite useful for keeping track of a variety of things (e.g. keeping track of user activity).

But I've been wondering: what happens if your server goes down? I know that anything in RAM is lost when the computer is off...so couldn't even a moment of downtime be disastrous for an application that stores a lot of important information via Redis? Or am I missing something?

01 Apr
2 years ago

TheFriendlyHacker started a new conversation How/where To Build A Laravel Package?

I want to start working on a new Laravel package. I am familiar with all of the steps/components required for doing so (e.g., composer, service providers, etc), however I'm not sure where I should put my package while I am working on it/

To be more specific, when you install a package via composer, it is placed in the vendor folder. But when I am building/working on the package, where should I put the code? Should it go under the app folder (e.g. /app/MyPackage/src/)?

Thanks!

28 Feb
2 years ago

TheFriendlyHacker left a reply on Does Eloquent Use Indexes?

I know you can add indexes in Laravel's schema builder and all.

What's got my confused is the MySQL/MariaDB 'FORCE INDEX' statement. I'm just not sure if you need to hint/force an index in order for it to be used, or if the database will automatically pick up on it and use them on its own.

TheFriendlyHacker started a new conversation Does Eloquent Use Indexes?

So, this may seem like a rather silly question. But I'm a bit new to "advanced" database concepts.

I've read that, with MySQL/MariaDB, you can use the INDEX hint in your query to make use of your indexes.

EXPLAIN SELECT Name,CountryCode FROM City FORCE INDEX (Name)
WHERE name>="A" and CountryCode >="A";

So my questions are:

Does Eloquent use index hinting automatically?

Will MySQL/MariaDB not use indexes if you don't hint them?

23 Feb
2 years ago

TheFriendlyHacker started a new conversation MariaDB: Allocate Memory To One Specific Database

You can allocate memory to MariaDB by setting the innodb_buffer_pool_size in your my.cnf.

However, it seems to split the memory you allocate in innodb_buffer_pool_size between all of the databases. So if, for example, you have 8 databases and set innodb_buffer_pool_size to 4GB, each DB will only get 512mb.

Is there a way to allocate a certain amount of memory to a specific database? I have several databases, one of which needs a lot more memory than the others.