I just checked laravel octane doc and it boots your application once, keeps it in memory, opcache stores precompiled script bytecode in shared memory, thereby removing the need for PHP to load and parse scripts on each request. English is my second language so both of them sound similar to me. Can somebody explain what is real difference between them in more practical way? submitted by /u/azamjon9
[link] [comments]
08 July, 2023
07 July, 2023
Design Emails and Send Them Via API with MailCarrier
Programing Coderfunda
July 07, 2023
No comments
MailCarrier is an open-source web app built with Laravel and Filament, where you can design emails once and send them via an API call.
The post Design Emails and Send Them Via API with MailCarrier appeared first on Laravel News.
Join the Laravel Newsletter to get Laravel articles like this directly in your inbox.
---
06 July, 2023
ChatGPT Mock API Generator for Laravel
Programing Coderfunda
July 06, 2023
No comments
The ChatGPT Mock API Generator package for Laravel generates smart API mocks in Laravel using ChatGPT prompts.
The post ChatGPT Mock API Generator for Laravel appeared first on Laravel News.
Join the Laravel Newsletter to get Laravel articles like this directly in your inbox.
---
05 July, 2023
What are you guys using for shopping cart/e-commerce solutions?
Programing Coderfunda
July 05, 2023
No comments
I built an e-commerce application all the way back in L5 using just a simple shopping cart package.
I was wanting to get into a multi-vendor marketplace type of e-commerce site and basic searches didn’t pull up anything specific.
I planned on custom writing everything with InertiaJS and Vue 3 so any packages around Laravel/Vue 3 that could ease some of my work would be great. submitted by /u/wtfElvis
[link] [comments]
04 July, 2023
Writing and debugging Eloquent queries with Tinkerwell
Programing Coderfunda
July 04, 2023
No comments
In this article, let's look into the options that you can use with Tinkerwell to write and debug Eloquent queries easier.
The post Writing and debugging Eloquent queries with Tinkerwell appeared first on Laravel News.
Join the Laravel Newsletter to get Laravel articles like this directly in your inbox.
---
03 July, 2023
libxml2-Question about xmlCreateFileParserCtxt
Programing Coderfunda
July 03, 2023
No comments
I'm confused about the return value. I think the ret is a newly allocated memory, and I need to free it by using xmlFreeParserCtxt. But when I remove xmlFreeParserCtxt, I found there is no error and I'm sure the ret value is not NULL!(I use fsanitize=address to detect)
If the ret value of xmlCreateFileParserCtxt is not NULL, is it possible that it isn't newly allocated?
My code:
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
int main() {
const char* xmlFilePath = "example.xml";
// Create a parser context for parsing an XML file
xmlParserCtxtPtr ctxt = xmlCreateFileParserCtxt(xmlFilePath);
if (ctxt == NULL) {
printf("Failed to create parser context for file: %s\n", xmlFilePath);
return 1;
}
// Cleanup
// xmlFreeParserCtxt(ctxt);
return 0;
}
First, I add the xmlFreeParserCtxt(ctxt);, I'm sure there is no error msg. And then, I delete this line. I compile this code by: gcc ./test.c -g -lxml2 -fsanitize=address.I think I should got error output, but nothing happened. No memleaks!
Client not receiving session data from server using Node, Passport JS, and cookie-session
Programing Coderfunda
July 03, 2023
No comments
so i've been using development servers this entire time, and everything's worked fine. Now, as I've deployed my client and backend, i'm running into an issue where my client cannot grab the sessional data from the cookie. i've checked both the backend and client cookies, and it seems like the session and session.sig are identical, so i don't know what's the deal... here's the relevant code:
my backend:
server.js:
dotenv.config({ path: "./.env" });
const cookieKey = process.env.COOKIE_KEY;
const express = require("express");
const cookieSession = require("cookie-session");
const connectDB = require("./config/db");
const passport = require("passport");
const PORT = process.env.PORT || 4500;
const cors = require("cors");
connectDB();
const app = express();
//middleware
app.use(express.json());
app.use(
cors({
origin: true, // replace with your frontend domain
credentials: true,
})
);
app.use(
cookieSession({
maxAge: 24 * 60 * 60 * 1000, // 1 day
keys: [cookieKey],
cookie: {
secure: true,
sameSite: "none",
},
})
);
app.use(passport.initialize());
app.use(passport.session());
const authentication = require("./routes/Authentication.js");
app.use("/api/v1/auth", authentication);
const tabs = require("./routes/Tabs.js"); // Adjust the path as necessary
app.use("/api/v1/tabs", tabs);
const preferences = require("./routes/Preferences.js");
app.use("/api/v1/preferences", preferences);
const google = require("./routes/Google.js"); // Adjust the path as necessary
app.use("/api/v1/google", google);
app.listen(PORT, () => console.log("Server is connected"));
authentication.js:
dotenv.config({ path: "./.env" });
const sucessRedirectURL = process.env.SUCCESS_REDIRECT_URL;
const express = require("express");
const passport = require("passport");
require("../services/Passport");
const router = express.Router();
router.get(
"/google",
passport.authenticate("google", {
scope: ["profile", "email", "https://www.googleapis.com/auth/calendar"],
accessType: "offline",
approvalPrompt: "force",
})
);
router.get(
"/google/callback",
passport.authenticate("google", {
successRedirect: sucessRedirectURL,
})
);
router.get("/me", (req, res) => {
if (req.user) {
res.send(req.user);
} else {
res.status(401).json({ message: "Not authenticated" });
}
});
router.get("/logout", (req, res) => {
console.log("logging out");
req.logout();
res.redirect("/");
});
module.exports = router;
and my own service file, passport.js:
dotenv.config({ path: "./.env" });
const googleClientID = process.env.GOOGLE_CLIENT_ID;
const googleClientSecret = process.env.GOOGLE_CLIENT_SECRET;
const backendAppURL = process.env.BACKEND_APP_URL;
const passport = require("passport");
const GoogleStrategy = require("passport-google-oauth20");
const User = require("../models/User");
//when a user logs in, we get a 'user object' which is serialized to our session by storing a user's ID,
//which is called automatically after logging
passport.serializeUser((user, done) => {
done(null, user.id);
});
//now, when we want to take the data stored in our session, we use the ID to recreate the full user object on
//each request, which is automatically done on each request
passport.deserializeUser((id, done) => {
User.findById(id).then((user) => {
done(null, user);
});
});
//this code happens first to find/create a user object
passport.use(
new GoogleStrategy(
{
clientID: googleClientID,
clientSecret: googleClientSecret,
callbackURL: backendAppURL + "/api/v1/auth/google/callback", //FULL CALLBACK URL IN PRODUCTION VS RELATIVE PATH IN DEVELOPMENT
},
async (accessToken, refreshToken, profile, done) => {
try {
const existingUser = await User.findOneAndUpdate(
{ googleId: profile.id },
{
accessToken,
refreshToken,
name: profile.displayName,
avatarUrl: profile.picture,
isVerified: profile.emails[0].verified,
}
);
if (existingUser) {
console.log("Existing user found:", existingUser);
return done(null, existingUser);
}
const user = await new User({
accessToken,
refreshToken,
name: profile.displayName,
email: profile.emails[0].value,
googleId: profile.id,
avatarUrl: profile.picture,
isVerified: profile.emails[0].verified,
}).save();
console.log("New user saved:", user);
done(null, user);
} catch (error) {
console.error("Error during authentication: ", error);
done(error);
}
}
)
);
here's the backend cookie:
02 July, 2023
Canvas - not drawing at correct position
Programing Coderfunda
July 02, 2023
No comments
I have a canvas wrapped in dialog element and I have implemented a drawing app so I can draw something on canvas but it's not drawing on correct position of touch
Html
close
Open
#d {
border:none;outline:none;
padding:0;
}
Js
const ctx = c.getContext("2d")
const size = 5 ,
Color = "red" ,
cx = ((screen.width - c.width ) / 2) - 25,
cy = ((screen.height - c.height) / 2) - 25
console.log(cx,cy)
let sx = 0 , sy = 0
c.ontouchstart = (e) => {
const t = e.touches[0]
sx = t.clientX - cx
sy = t.clientY - cy
}
c.ontouchmove = (e) => {
const t = e.touches[0]
ctx.beginPath()
ctx.moveTo(sx,sy)
ctx.lineTo(t.clientX - cx, t.clientY - cy)
ctx.lineWidth = size
ctx.strokeStyle = Color
ctx.lineCap = "round"
ctx.stroke()
sx = t.clientX - cx
sy = t.clientY - cy
}


