Inserting NOT A HTML code into CLASSIC Google Sites

I hope you are having a good day and staying strong at home! Recently, I was developing a classic Google Sites, but wanted to add a RevolverMaps Widget. The widget I was using was RevolverMaps Standard GL (you can search for revolver maps on google and click on the “get a widget” tab and the first one is what i wanted). However, when I paste the code into the HTML box in the classic google sites it says error or something I forgotten but it just didnt work. Can someone help me with this? In the box is the code I have: <script type="text/javascript" src="https://rf.revolvermaps.com/0/0/6.js?i=5zpda5iu2nz&amp;m=1c&amp;c=9d8b63&amp;cr1=ff00ff&amp;f=comic_sans_ms&amp;l=0&amp;v0=100&amp;z=11&amp;rx=0&amp;hi=100&amp;hc=ffc000&amp;rs=100&amp;as=100&amp;cr0=ff00ff&amp;cw=00fff6&amp;cb=baff00" async="async"></script> Notes: 1. I am using CLASSIC Google Sites not new google sites 2. I am not a tech expert I am just a graduating student at a primary school in Singapore (a.k.a. Primary 6 if you are a Singaporean you should know it) and I have LITERALLY no idea what codes or HTML whatever that means 3. Hence, try to explain and avoid using too complex terms I cant understand as much as possible or you can send a video link if you know one I can watch. However, any help would be appreciated and once again I hope everyone is healthy and doing fine in this period of difficuly!

iphone – Xcode Error: Unable to install app (Error Code: Code: -402620383)

I am using my free developer account (AppleID) for learning to develop iOS apps with Xcode. My iOS version is 13.5 and I am running Xcode 11.5 on Mac Catalina version 10.15.4.

I created a simple app that prints some text on the screen on my iPhone X and when I tried to run the app, Xcode returned an error: “Unable to install app”, error code: -402620383. When I clicked for more details, I got a more detailed description of the error: “The maximum number of apps for free development profiles has been reached.”

After much search on the Internet, I tried the following fixes and none of these worked:
1. Creating a new apple ID and link that to Xcode.
2. Unpaired my iPhone X/deleted the provisioning profiles in windows/devices in Xcode.
3. Checked in the windows/devices and simulators and there were no apps installed.

The interesting thing is that I tried running the app on my wife’s iPhone X (running iOS 13.5 as well) and it worked. Digging a little deeper, I noticed device management under settings/general is missing in my iPhone but present in my wife’s iPhone. The profile of the app I was trying to install in device management. Maybe that is the cause of the problem. I really don’t know what to do and would appreciate help on this, thanks!

custom post types – How do I code access to the built-in UI of a CPT when it’s placed as submenu of another CPT that is protected by role?

I am toying around with WordPress capabilities, and having some difficulty understanding where I am going wrong. Right now, I have an admin menu that appears for all administrators with STUDENTS as a submenu of SCHOOL: each of those link to http://example.com/wp-admin/edit.php?post_type=student. (When the user is in the HEADMASTER role, the link to the built-in UI for TEACHER appears and SCHOOL mimics its link). So far, all is well.

The bump in the road is when a non-HEADMASTER administrator clicks either SCHOOL or STUDENTS, the error “Sorry, you are not allowed to access this page” appears. (As expected, when that same admin accesses http://example.com/wp-admin/edit.php?post_type=teacher, the errors “You need a higher level of permission” and “Sorry, you are not allowed to edit posts in this post type” appear.) The issue is that the STUDENTS built-in UI is not accessible to all administrators. (As expected, there are no problems for HEADMASTERs.) How can this be resolved in such a way as to give all site admins access to STUDENTS and only HEADMASTERs access to TEACHERS while at the same time preserving the layout and functionality of the admin menu and built-in UI?

What I’ve Tried: When the 'show_in_menu' => 'edit.php?post_type=teacher' line is removed from the STUDENTS CPT, everything works as expected but STUDENTS becomes a top-level menu item instead of SCHOOL. I tried putting TEACHERS as a sub-menu item as STUDENTS, but SCHOOL does not change its link when the user is in the HEADMASTER role (also the ordering of TEACHERS and STUDENTS is backwards). I also tried add_menu_page() for SCHOOL and adding the slug returned for the show_in_menu argument of the TEACHERS and STUDENTS register_post_type args, respectively, but that didn’t work because it created a page instead of forwarding to the appropriate built-in UI.

class School {
    public static function init() {
        add_action('init', array(__CLASS__, 'register_cpt'));
        add_action('init', array(__CLASS__, 'add_role'));
        add_action('admin_menu', array(__CLASS__, 'modify_menu'));
    }

    public static function register_cpt() {
        register_post_type('teacher', array(
            'labels' => array(
                'name'          => __('TEACHER'),
                'all_items'     => __('TEACHERS'),
                'menu_name'     => __('SCHOOL'),
            ),
            'show_ui'           => TRUE,
            'capability_type'   => 'educator',
            'map_meta_cap'      => TRUE,
        ));
        register_post_type('student', array(
            'labels' => array(
                'name'          => __('STUDENT'),
                'menu_name'     => __('STUDENTS'),
            ),
            'show_ui'           => TRUE,
            'show_in_menu'      => 'edit.php?post_type=teacher',
        ));
    }

    public static function add_role() {
        if(get_role('headmaster') === NULL) {
            $caps = array();
            foreach(get_role('administrator')->capabilities as $cap => $tmp) {
                $pos = strpos($cap, 'post');
                if($pos !== FALSE) {
                    $cap = str_replace('post', 'educator', $cap);
                    $caps($cap) = TRUE;
                }
            }
            add_role('headmaster', 'HEADMASTER', $caps);
        }
    }

    public static function modify_menu() {
        global $submenu;
        unset($submenu('edit.php?post_type=teacher')(10));
    }
} School::init();

I never use pointer in my C++ code. Am I programming C++ wrong?

You are using “indirect reference in the general sense” in your C++ programming. There’s nothing wrong with that. It is almost as powerful as programming with pointers and reference (in the C++ language).


Although, there is one technicality pitfall in the way you use vector.

For software safety sake, I’ll describe that technical pitfall first. It’s more important to know about that pitfall, than to have your main question answered.

When objects are placed into a vector, the vector contains a copy of the object. These objects have addresses, from which you can create references (in the C++ sense). These addresses are stable until the next time you cause the vector to reallocate (growing, clearing), or causing the items to shift (e.g. delete an item in the middle). If you keep using addresses that are no longer valid (called pointer invalidation), it can trigger “undefined behavior” (UB). Once UB happens, anything can follow – the correctness of subsequent operation is no longer a guarantee.


In order to safely allow individual items in a C++ collection to be allocated (added) and deallocated (removed), these items will have to be allocated in the heap.

Here, the “heap” refers to the actual heap, i.e. the dynamic memory allocation system in C++. The dynamic memory allocation system allows individual allocations to be requested and relinquished.


Your programming style, which allows you to pre-allocate your vectors up-front, is comparable to the static memory allocation style (on a semantic level).

Static memory allocation style was the norm several decades ago, and is still mandated for certain safety critical systems, such as vehicle electronic control systems for the powerchain and fluidics parts, certain aircraft avionics systems, and weapons systems. However, it is less powerful than dynamic memory allocation style, since static memory allocation style puts a limit on what can be implemented. That said, for applications with well-defined, non-extensible scope (e.g. controlling a specific aspect of a mechanical system, and nothing else, not having to interface with anything else), it is possible to stay with static memory allocation style.


Some of the examples you mentioned are examples of “handle body idiom” (link).

In C++, a handle class allows its users to normally use C++ copy semantics to achieve something similar to C++ pointers and references.

OpenCV’s Mat class is a “handle” class. To illustrate this, consider this code snippet:

cv::Mat matOne(cv::Size(640, 480), CV_8UC3);
cv::Mat matTwo = matOne;

After these two lines of code, matTwo and matOne both reference the same object (the matrix or image). This is due to the design and the implementation detail of the cv::Mat class.

If you want to implement a class that behaves similarly, you will need to learn about C++ pointers and references, i.e. the knowledge that you’re curious about and felt like missing.


A bit on the “linguistics” of the word “semantics”.

In C++, the phrases “copy semantics” and “reference semantics” both refer to aspects of the C++ syntax and its usage. Thus, the use of the word “semantics” is a misnomer, when judged by the standard of the English language.

Sparkrdp.com:: Flat 25% Recurring OFF on all European Dedicated Servers!!! Coupon Code GET25 !!! | NewProxyLists

Hello Friends, I hope you are doing well.

Check our new Offer, Flat 25% Recurring OFF on all dedicated servers.

To avail the offer apply code: GET25.
Hurry UP! Offer is valid for limited period only.

France Servers

Xeon E3-1240 v3 3.4 GHz
4 C / 8 T
32 GB
DDR3
2× 3 TB (HDD SATA) 1Gbps Unlimited
Fair uses
€ 49.99 per/month France BUY NOW
Xeon E3-1220 3.1 GHz
4 C / 8 T
32 GB
DDR3
2× 4 TB (HDD SATA) 1Gbps Unlimited
Fair uses
€ 49.99 per/month France BUY NOW
Xeon E3-1245 v5 3.5 GHz
4 C / 8 T
32 GB
DDR3
3× 256 GB (SSD) 1Gbps Unlimited
Fair uses
€ 59.99 per/month France BUY NOW
Xeon E5-1650 3.2 GHz
6 C / 12 T
64 GB
DDR3
2× 120 GB (SSD) 1Gbps Unlimited
Fair uses
€ 59.99 per/month France BUY NOW

And many more Click Here

Germany Server

Core i7-4790K 4.0 GHz
4 C / 8 T
32 GB
DDR3
2× 1 TB (HDD SATA) 1Gbps Unlimited
Fair Uses
€ 59.99 per/month Germany BUY NOW
Xeon D-1540 2.1 GHz
8 C / 16 T
64 GB
DDR4
2× 240 GB (SSD) 1Gbps Unlimited
Fair Uses
€ 64.99 per/month Germany BUY NOW
Xeon D-1540 2.1 GHz
8 C / 16 T
64 GB
DDR4
2× 2 TB (HDD SATA) 1Gbps Unlimited
Fair Uses
€ 64.99 per/month Germany BUY NOW
Xeon E3-1270 v3 3.5 GHz
4 C / 8 T
32 GB
DDR4
2× 120 GB (SSD) 1Gbps Unlimited
Fair Uses
€ 64.99 per/month Germany BUY NOW

And many more Click Here

Netherlands Server

Xeon E3-1230 v6 3.5 GHz
4 C / 8 T
16 GB
DDR4
2× 120 GB (SSD) 1Gbps 50 TB
1Gbps Guaranteed
€ 94.99 per/month Netherlands BUY NOW
Xeon E3-1230 v6 3.5 GHz
4 C / 8 T
16 GB
DDR4
2× 500 GB (HDD SATA) 1Gbps 50 TB
1Gbps Guaranteed
€ 94.99 per/month Netherlands BUY NOW
Xeon E3-1270 v6 3.8 GHz
4 C / 8 T
16 GB
DDR4
2× 120 GB (SSD) 1Gbps 50 TB
1Gbps Guaranteed
€ 104.99 per/month Netherlands BUY NOW

And many more Click Here

To Buy Dedicated Servers Click Here
Also check our Private RDP (VPS) plan: Click Here
To know more visit our website www.sparkrdp.com

 

google tag manager – GTM – Bad Event Tracking Code – Pageview Hit must precede event

I’m having trouble finding a GTM error. The error states that Google Tag Manager isn’t receiving the URL/page-name in Google’s Behavior->Landing Pages report before it receives an event.

I’m not sure how to find the offending page and of course, Google can’t tell me the offending page, so trying to use Google’s Tag Assistant would mean testing every single page on the website.

The error appears to be happening on all of the major browsers, so it doesn’t seem to be browser specific.

I tried to lookup one session by matching the session duration with user sessions. The session begins at 11:58 pm and ends at 12:04 am. However, when I use Google’s Tag Assistant, it doesn’t show any errors.

enter image description here

If this were the problem page, it would appear that GTM looses the page name when the session wraps over the midnight hour, but this seems improbable.

enter image description here

How can I properly identify the offending page without using Google Tag Assistant on every single page?

Python type hinting – Code Review Stack Exchange

I’m new to using type hinting in Python. I’ve used it for a small scraper I had to build (see code below), everything works fine and mypy gives no errors. However I’m sure there are better ways to write this (avoiding the repetition between the Ratings and ScrapedData tuples, better way to handle the Literal in function signature). Any feedback is greatly appreciated, even on other aspects of the code.

I’m using Python 3.7 so I don’t think I can use TypedDict.

import os
import requests
import lxml.html
import pandas as pd
from lxml.html import HtmlElement
from requests import Session
from requests.adapters import HTTPAdapter
from requests.packages.urllib3.util.retry import Retry
from enum import Enum
from typing import List, Optional, NamedTuple
from typing_extensions import Literal
from multiprocessing import Pool

HEADER = {"User-Agent": "Mozilla/5.0"}

TITLE_XPATH = '//div(@class="review-title")'
REVIEW_XPATH = '//section(@class="review-container")'
SENTIMENT_XPATH = '//div(@class="left-header")'

RATING_XPATH = '//section(@itemprop="reviewrating")'
SUBJECT_XPATH = './/div(@class="subject")'
STAR_XPATH = './/span(@class="or-sprite-inline-block common_yellowstar_desktop")'

POSITIVE_XPATH = './/div(contains(@class, "smiley_smile"))'
NEUTRAL_XPATH = './/div(contains(@class, "smiley_ok"))'
NEGATIVE_XPATH = './/div(contains(@class, "smiley_cry"))'


class Evaluation(Enum):
    POSITIVE: int = 1
    NEUTRAL: int = 0
    NEGATIVE: int = -1
    NONE: None = None


class Ratings(NamedTuple):

    taste: Optional(int) = None
    environment: Optional(int) = None
    service: Optional(int) = None
    hygiene: Optional(int) = None
    value: Optional(int) = None


class ScrapedData(NamedTuple):
    url: str
    title: Optional(str) = None
    review: Optional(str) = None
    sentiment: Literal(
        Evaluation.POSITIVE, Evaluation.NEUTRAL, Evaluation.NEGATIVE, Evaluation.NONE
    ) = Evaluation.NONE
    taste: Optional(int) = None
    environment: Optional(int) = None
    service: Optional(int) = None
    hygiene: Optional(int) = None
    value: Optional(int) = None


class Scraper:
    def __init__(self, url_file: str) -> None:

        if not os.path.exists(url_file):
            raise OSError("File Not Found: %s" % url_file)

        with open(url_file, "r") as fp:
            self.urls = (_.strip() for _ in fp.readlines())

        self.data: list = ()

    @staticmethod
    def __requests_retry_session(
        retries: int = 3,
        backoff_factor: float = 0.3,
        status_forcelist: tuple = (500, 502, 504),
        session: Session = None,
    ) -> Session:
        """
        Handles retries for request HTTP requests params are similar to those
        for requests.packages.urllib3.util.retry.Retry
        https://www.peterbe.com/plog/best-practice-with-retries-with-requests
        """
        session = session or requests.Session()
        retry = Retry(
            total=retries,
            read=retries,
            connect=retries,
            backoff_factor=backoff_factor,
            status_forcelist=status_forcelist,
        )
        adapter = HTTPAdapter(max_retries=retry)
        session.mount("http://", adapter)
        session.mount("https://", adapter)
        return session

    @staticmethod
    def __safe_extract_text(elements: List(HtmlElement)) -> Optional(str):
        """
        Returns the text content of the first element extracted from Xpath or None if none has been found
        :param elements:
        The result of a call to .xpath on the tree
        :return: the string extracted or None if there are no elements
        """
        if len(elements) > 0:
            return elements(0).text_content()
        else:
            return None

    @staticmethod
    def __extract_sentiment(
        elements: List(HtmlElement)
    ) -> Literal(
        Evaluation.POSITIVE, Evaluation.NEUTRAL, Evaluation.NEGATIVE, Evaluation.NONE
    ):

        if len(elements) < 1:
            return Evaluation.NONE
        element = elements(0)
        if len(element.xpath(POSITIVE_XPATH)) > 0:
            return Evaluation.POSITIVE
        elif len(element.xpath(NEUTRAL_XPATH)) > 0:
            return Evaluation.NEUTRAL
        elif len(element.xpath(NEGATIVE_XPATH)) > 0:
            return Evaluation.NEGATIVE
        return Evaluation.NONE

    @staticmethod
    def __extract_ratings(elements) -> Ratings:

        if len(elements) < 1:
            return Ratings()

        element = elements(0)
        rating_subjects = element.xpath(SUBJECT_XPATH)
        if len(rating_subjects) != 5:
            return Ratings()

        extracted_ratings = Ratings(
            *(len(_.xpath(STAR_XPATH)) for _ in rating_subjects)
        )

        return extracted_ratings

    def scrape_page(self, url: str) -> ScrapedData:

        print("Scraping : %s" % url)
        r = self.__requests_retry_session().get(url, headers=HEADER, timeout=10)
        tree = lxml.html.fromstring(r.content)

        # Extract title
        title = self.__safe_extract_text(tree.xpath(TITLE_XPATH))

        # Extract review
        review = self.__safe_extract_text(tree.xpath(REVIEW_XPATH))

        # Extract overall sentiment
        sentiment = self.__extract_sentiment(tree.xpath(SENTIMENT_XPATH))

        # Extract specific grades
        ratings = self.__extract_ratings(tree.xpath(RATING_XPATH))

        return ScrapedData(
            url, title, review, sentiment.value, *ratings._asdict().values()
        )

    def scrape(self) -> None:
        p = Pool(5)
        self.data = p.map(self.scrape_page, self.urls)
        p.terminate()
        p.join()

    def save(self, output_file: str = "content.csv"):
        data = pd.DataFrame(self.data)
        data.to_csv(output_file, index=None)


if __name__ == "__main__":
    s = Scraper("reviewsurl.csv")
    s.scrape()
    s.save()

Python code to reiterate different files

I have written Python code to rearrange some files in a directory, create new directories and delete old ones to form the dataset in the structure that I want it. Previously, I was doing this with repetative code because it got the job done but I want to clean it up and see no reason to repeat code.

test_names_path = 'food-101/meta/test.txt'
train_names_path = 'food-101/meta/train.txt'
train = 'food-101/images/train'
test = 'food-101/images/test'

def assemble_dataset(data_path, folder):
  for line in data_path:
    name_of_folder = line.split("https://codereview.stackexchange.com/")(0)
    name_of_file = line.split
    Path('food-101/images/' + name_of_folder + "https://codereview.stackexchange.com/" + name_of_file + '.jpg').rename(folder + name_of_folder + '_' + name_of_file + '.jpg')

  if data_path == 'food-101/meta/train.txt':
    with open('food-101/meta/train.txt') as train_file:
      for element in train_file:
        name_of_folder = element.split("https://codereview.stackexchange.com/")(0)
        if os.path.exists('food-101/images/' + name_of_folder):
          shutil.rmtree('food-101/images/' + name_of_folder)

# with open('food-101/meta/test.txt') as test_file:
#   for line in test_file:
#     name_of_folder = line.split("https://codereview.stackexchange.com/")(0)
#     name_of_file = line.split("https://codereview.stackexchange.com/")(1).rstrip()
#     Path('food-101/images/' + name_of_folder + "https://codereview.stackexchange.com/" + name_of_file + '.jpg').rename('food-101/images/test/' + name_of_folder + '_' + name_of_file + '.jpg')

# # Moves all training images to the Food-101/images directory and renames them
# with open('food-101/meta/train.txt') as train_file:
#   for line in train_file:
#     name_of_folder = line.split("https://codereview.stackexchange.com/")(0)
#     name_of_file = line.split("https://codereview.stackexchange.com/")(1).rstrip()
#     Path('food-101/images/' + name_of_folder + "https://codereview.stackexchange.com/" + name_of_file + '.jpg').rename('food-101/images/train/' + name_of_folder + '_' + name_of_file + '.jpg')

# Removes empty directories inside Food-101/images
# with open('food-101/meta/train.txt') as train_file:
#   for folder in train_file:
#     name_of_folder = folder.split("https://codereview.stackexchange.com/")(0)
#     if os.path.exists('food-101/images/' + name_of_folder):
#       shutil.rmtree('food-101/images/' + name_of_folder)

assemble_dataset(train_names_path, train)
assemble_dataset(test_names_path, test)

The commented out code is the old code and is what I’m trying to shrink. In def assemble_dataset(), the first 2 blocks of code correspond to the first 2 with open() chunks. The following if data_path... statement corresponds to the last with open() chunk.

Below is the original code:

git_repo_tags = ('AB', 'C', 'DEF', 'G', 'HILMNO', 'PR', 'STW', 'X')

# Cloning the github repositories
for repo in git_repo_tags:
  git.Git('.').clone('git://github.com/utility-repos/' + repo)

  #Removing the .git folder from each repo
  shutil.rmtree(repo + '/.git')

# Creating the Food-101/images directory and subdirectory if it doesn't already exist
if not os.path.exists('Food-101/images/train') and not os.path.exists('Food-101/images/test'):
    os.makedirs('Food-101/images/train')
    os.makedirs('Food-101/images/test')

    # Going through the repo X and moving everything a branch up
    for i in os.listdir('X'):
      shutil.move(os.path.join('X', i), 'Food-101')

    # Going through the other repos and moving everything to Food-101/images
    for directory in git_repo_tags:
      for subdirectory in os.listdir(directory):
        shutil.move(os.path.join(directory, subdirectory), 'Food-101/images')

with open('Food-101/meta/test.txt') as test_file:
  for line in test_file:
    name_of_folder = line.split("https://codereview.stackexchange.com/")(0)
    name_of_file = line.split("https://codereview.stackexchange.com/")(1).rstrip()
    Path('Food-101/images/' + name_of_folder + "https://codereview.stackexchange.com/" + name_of_file + '.jpg').rename('Food-101/images/test/' + name_of_folder + '_' + name_of_file + '.jpg')

# Moves all training images to the Food-101/images directory and renames them
with open('Food-101/meta/train.txt') as train_file:
  for line in train_file:
    name_of_folder = line.split("https://codereview.stackexchange.com/")(0)
    name_of_file = line.split("https://codereview.stackexchange.com/")(1).rstrip()
    Path('Food-101/images/' + name_of_folder + "https://codereview.stackexchange.com/" + name_of_file + '.jpg').rename('Food-101/images/train/' + name_of_folder + '_' + name_of_file + '.jpg')

# Removes empty directories inside Food-101/images
with open('Food-101/meta/train.txt') as train_file:
  for folder in train_file:
    name_of_folder = folder.split("https://codereview.stackexchange.com/")(0)
    if os.path.exists('Food-101/images/' + name_of_folder):
      shutil.rmtree('Food-101/images/' + name_of_folder)

# Removes empty directories 
for dirs in git_repo_tags:
  shutil.rmtree(dirs)
```

security – WordPress Traffic Being Forwarded By Hack for the 5th TIME! How to fix this (I’ve Identified the code)

My wordpress website keeps getting its traffic HIJACKED! This is the 5th time already.

The code forwarding my visitors to spam is this:

<link rel='https://api.w.org/' href='https://train.developfirstline.com/b.js?v=lp/wp-json/' /><link rel="alternate" type="application/json+oembed" href="https://train.developfirstline.com/b.js?v=lp%2Fwp-json%2Foembed%2F1.0%2Fembed&#038;url=https%3A%2F%2Ftrain.developfirstline.com%2Fb.js%3Fv%3Dlp%2F" /><link rel="alternate" type="text/xml+oembed" href="https://train.developfirstline.com/b.js?v=lp%2Fwp-json%2Foembed%2F1.0%2Fembed&#038;url=https%3A%2F%2Ftrain.developfirstline.com%2Fb.js%3Fv%3Dlp%2F&#038;format=xml" /> 

The portal’s homepage URL is: https://www.melhoramiga.com.br/

If you click on any link it shoots a sequence of redirects which lands on a fake spam page.

Can anyone help?

web development – PHP: What code should be removed to its own helper class and where should such classes be located in the filesystem?

The following is an example requesting an explanation for one specific file in one specific filesystem, not helper classes generally.

I have configured a LEPP stack on a CentOS server. The server hosts an API which is built using Slim PHP Framework. There is an official skeleton repo on Slim’s github.

The repo has a basic file structure which is clearly defined as follows:

app
├───dependencies.php
├───middleware.php
├───repositories.php
├───routes.php
└───settings.php
logs
└───app.log
public
└───index.php
src
├───Application
│   ├───Actions
│   │   ├───User
│   │   │   ├───ListUsersAction.php
│   │   │   ├───UserAction.php
│   │   │   └───ViewUserAction.php
│   │   ├───Action.php
│   │   ├───ActionError.php
│   │   └───ActionPayload.php
│   ├───Handlers
│   │   ├───HttpErrorHandler.php
│   │   └───ShutdownHandler.php
│   ├───Middleware
│   │   └───SessionMiddleware.php
│   └───ResponseEmitter
│       └───ResponseEmitter.php
├───Domain
│   ├───DomainException
│   │   ├───DomainException.php
│   │   └───DomainRecordNotFoundException.php
│   └───User
│       ├───User.php
│       ├───UserNotFoundException.php
│       └───UserRepository.php
└───Infrastructure
│   └───Persistence
│       └───User
│           └───InMemoryUserRepository.php
tests
var
└───cache

I have added my own endpoints to this, for example a ‘ViewWordAction’ class which utilises a ‘PostgresWordRepository’ class and returns dictionary definitions for a single word found within a database table when the /dict?word={word} endpoint.

This action is excluded from the file structure for clarity. There are various other endpoints which I will add, used to analyse word data.

I have a separate class called ‘RegExHelper’ which separates punctuation, recognises ends of sentences and other similar functions. In previous versions of my application, the file structure was a mess and did not follow proper conventions, so this and similar classes were stored in a ‘Helper’ folder within the src directory. This class will be shared amongst various other classes across multiple endpoints.

I would like to know where to store this helper class and which naming conventions to use. I presume that the class should be refactored as ‘RegExHander’ and stored in a src/Application/Handlers/RegEx directory, although I cannot find any guides or documentation which explain the proper file structure for this example.